lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: writer.tryDeleteDocument(..) does not delete document
Date Wed, 31 Oct 2012 16:10:55 GMT
This looks like a real bug!  Thanks for reporting it Ivan ... I'll
open an issue.

Mike McCandless

http://blog.mikemccandless.com

On Wed, Oct 31, 2012 at 11:41 AM, Ivan Vasilev <ivasilev@sirma.bg> wrote:
> Hy Guys,
>
> I use as suggested in question "Lucene 4.0 delete by ID" from 29.Oct -
> instead of reader.delete(docID) use - writer.tryDeleteDocument(..) method
> but for some reason it does not work.
>
> My code is:
>
> ........
>         <Here create an index with 3 docs in it>
>
>         IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_40, new
> StandardAnalyzer(Version.LUCENE_40));
>         iwc.setOpenMode(OpenMode.APPEND);
>         IndexWriter writer = new IndexWriter(indexDir, iwc);
>         IndexReader nrtReader = DirectoryReader.open(writer, false); //
> using "true" gives the same result
>         writer.tryDeleteDocument(nrtReader, 1); // using
> nrtReader.leaves().get(0).reader() gives the same result (I have only one
> segment)
>         nrtReader.close();
>         writer.close();
>
>         IndexReader ir = DirectoryReader.open(indexDir);
>         System.out.println("ir.numDeletedDocs(): " + ir.numDeletedDocs());
>         Bits liveDocs = MultiFields.getLiveDocs(ir);
>         System.out.println("liveDocs: " + liveDocs);
>
>         ir.close();
>         indexDir.close();
> .........................
>
> The output is:
>
> ir.numDeletedDocs(): 0
> liveDocs: null
>
> --------------------------
>
> This is just simple test - no merges or adding new docs after creation of
> the index.
>
> I need deleting by Lucene ID because we have Parallel Indexes and when
> deleting document I should delete the related documents from both indexes.
> So when having to delete some document I will have Term(s) that are only in
> one of the indexes of the parallel index and can use
> writer.deleteDocuments(term), but this will not help for the other index in
> same Parallel Index. So I will have to find docs matching the Term(s) and
> delete them in all sub-indexes of the Parallel Index.
>
> Cheers,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message