[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lucene-user
Subject:    Re: writer.tryDeleteDocument(..) does not delete document
From:       Michael McCandless <lucene () mikemccandless ! com>
Date:       2012-10-31 16:20:24
Message-ID: CAL8Pwkb=+=74O6t4onQgfNESuS4LbUz9DCxVSO4aPeA5=178zg () mail ! gmail ! com
[Download RAW message or body]

I opened https://issues.apache.org/jira/browse/LUCENE-4521 ...

Mike McCandless

http://blog.mikemccandless.com

On Wed, Oct 31, 2012 at 12:10 PM, Michael McCandless
<lucene@mikemccandless.com> wrote:
> 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic