You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Marc Sturlese <ma...@gmail.com> on 2009/01/21 12:03:21 UTC

check if document is deleted using indexwriter

Hey there,
I would like to know how to check if a document has been deleted if I am
using an IndexWriter and the fucntions deleteDocument or updateDocument.
I have seen that deleteDocument from IndexReader returns an integer but in
the IndexWriter's case it's a void.
Any advice?

Thanks in advance.

-- 
View this message in context: http://www.nabble.com/check-if-document-is-deleted-using-indexwriter-tp21580983p21580983.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: check if document is deleted using indexwriter

Posted by Michael McCandless <lu...@mikemccandless.com>.
Could you just call IndexReader.numDocs (after updating your docs &  
reopening
your reader)?

Mike

Marc Sturlese wrote:

>
> I am using IndexWriter updatedocument. If the doc has a duplicate it  
> will
> delete the old one and insert de new one. If it has no duplicates in  
> the
> index, it will just insert. I do it for 1000 every time and would  
> like to
> count how many times it deletes, to be able to count duplicates...
>
> Michael McCandless-2 wrote:
>>
>>
>> IndexWriter currently has no way to check if a doc is deleted; you'd
>> have to use IndexReader...
>>
>> The deleteDocuments methods in IndexWriter do not return a count
>> (unlike IndexReader) because the request is simply buffered and then
>> processed in bulk when the deletes are flush.  So at the time of that
>> call, IndexWriter does not know how many documents were affected by
>> the delete.
>>
>> But why do you need to check this in the first place?  EG searching
>> will never return to you a deleted document...
>>
>> Mike
>>
>> Marc Sturlese wrote:
>>
>>>
>>> Hey there,
>>> I would like to know how to check if a document has been deleted if
>>> I am
>>> using an IndexWriter and the fucntions deleteDocument or
>>> updateDocument.
>>> I have seen that deleteDocument from IndexReader returns an integer
>>> but in
>>> the IndexWriter's case it's a void.
>>> Any advice?
>>>
>>> Thanks in advance.
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/check-if-document-is-deleted-using-indexwriter-tp21580983p21580983.html
>>> Sent from the Lucene - Java Users mailing list archive at  
>>> Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/check-if-document-is-deleted-using-indexwriter-tp21580983p21602823.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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


Re: check if document is deleted using indexwriter

Posted by Marc Sturlese <ma...@gmail.com>.
I am using IndexWriter updatedocument. If the doc has a duplicate it will
delete the old one and insert de new one. If it has no duplicates in the
index, it will just insert. I do it for 1000 every time and would like to
count how many times it deletes, to be able to count duplicates...

Michael McCandless-2 wrote:
> 
> 
> IndexWriter currently has no way to check if a doc is deleted; you'd  
> have to use IndexReader...
> 
> The deleteDocuments methods in IndexWriter do not return a count  
> (unlike IndexReader) because the request is simply buffered and then  
> processed in bulk when the deletes are flush.  So at the time of that  
> call, IndexWriter does not know how many documents were affected by  
> the delete.
> 
> But why do you need to check this in the first place?  EG searching  
> will never return to you a deleted document...
> 
> Mike
> 
> Marc Sturlese wrote:
> 
>>
>> Hey there,
>> I would like to know how to check if a document has been deleted if  
>> I am
>> using an IndexWriter and the fucntions deleteDocument or  
>> updateDocument.
>> I have seen that deleteDocument from IndexReader returns an integer  
>> but in
>> the IndexWriter's case it's a void.
>> Any advice?
>>
>> Thanks in advance.
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/check-if-document-is-deleted-using-indexwriter-tp21580983p21580983.html
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/check-if-document-is-deleted-using-indexwriter-tp21580983p21602823.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: check if document is deleted using indexwriter

Posted by Michael McCandless <lu...@mikemccandless.com>.
IndexWriter currently has no way to check if a doc is deleted; you'd  
have to use IndexReader...

The deleteDocuments methods in IndexWriter do not return a count  
(unlike IndexReader) because the request is simply buffered and then  
processed in bulk when the deletes are flush.  So at the time of that  
call, IndexWriter does not know how many documents were affected by  
the delete.

But why do you need to check this in the first place?  EG searching  
will never return to you a deleted document...

Mike

Marc Sturlese wrote:

>
> Hey there,
> I would like to know how to check if a document has been deleted if  
> I am
> using an IndexWriter and the fucntions deleteDocument or  
> updateDocument.
> I have seen that deleteDocument from IndexReader returns an integer  
> but in
> the IndexWriter's case it's a void.
> Any advice?
>
> Thanks in advance.
>
> -- 
> View this message in context: http://www.nabble.com/check-if-document-is-deleted-using-indexwriter-tp21580983p21580983.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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