lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <...@teamware.com>
Subject Re: [Urgent] deleteDocuments fails after merging ...
Date Tue, 13 Mar 2007 21:13:02 GMT
Erick Erickson wrote:
> The javadocs point out that this line
> 
> * int* nb = mIndexReaderClone.deleteDocuments(urlTerm)
> 
> removes*all* documents for a given term. So of course you'll fail
> to delete any documents the second time you call
> deleteDocuments with the same term.

Isn't the code snippet below doing a search before attempting the deletion, so 
from the IndexReader's point of view (as used by the IndexSearcher) the item 
exists.  What is mIndexReaderClone?  Is that the same reader that is used in 
IndexSearcher?

I'm not sure, but if you search with one IndexReader and delete the document 
using another IndexReader and then repeat the process, I think that the search 
would still result in a hit, but the deletion would return 0.

> On 3/13/07, DECAFFMEYER MATHIEU <MATHIEU.DECAFFMAYER@fortis.lu> wrote:
>>
>> Before I delete a document I search it in the index to be sure there is a
>> hit (via a Term object),
>> When I find a hit I delete the document (with the same Term object),

>> Hits hits = search(query);
>> *if* (hits.length() > 0) {
>>        * if* (hits.length() > 1) {
>>                 System.out.println("found in the index with duplicates");
>>         }
>>         System.out.println("found in the index");
>>        * try* {
>>                * int* nb = mIndexReaderClone.deleteDocuments(urlTerm);
>>                * if* (nb > 0)
>>                         System.out.println("successfully deleted");
>>                * else*
>>                        * throw** new* IOException("0 doc deleted");
>>         }* catch* (IOException e) {
>>                 e.printStackTrace();
>>                * throw** new* Exception(
>>                         Thread.currentThread().getName() + " --- Deleting

Antony


---------------------------------------------------------------------
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