Can somebody please clarify the intended behaviour of
IndexReader.deleteDocuments()?, between the various documentations and
implementations it seems this function is broken. API doc says it should
delete docs containing the provided term but instead it deletes all
documents not containg the given term.

On 10/15/06, EDMOND KEMOKAI <[EMAIL PROTECTED]> wrote:

Thanks for the response Otis, below is a link to the javadoc in the API:

http://lucene.apache.org/java/docs/api/org/apache/lucene/demo/DeleteFiles.html

( Deletes documents from an index that do not contain a term)

Here is a link to the actual sample implementation:

http://svn.apache.org/repos/asf/lucene/java/trunk/src/demo/org/apache/lucene/demo/DeleteFiles.java

In the file above you have code that looks like this:

      Term term = new Term("path", args[0]);

      int deleted = reader.deleteDocuments(term);

So in effect it should delete documents that don't contain the "path"
value correspoding to what's in args[0]. Except the API documentation
suggests the opposite. In other words the above code should delete only
documents containing "path" values equal to args[0] (this is obviously more
intuitive). Here is the API doc for what the above code snippet should do:

(http://lucene.apache.org/java/docs/api/org/apache/lucene/index/IndexReader.html#deleteDocuments(org.apache.lucene.index.Term)

<http://lucene.apache.org/java/docs/api/org/apache/lucene/index/IndexReader.html#deleteDocuments%28org.apache.lucene.index.Term%29>
):

Deletes all documents containing term. This is useful if one uses a
document field to hold a unique ID string for the document. Then to delete
such a document, one merely constructs a term with the appropriate field and
the unique ID string as its text and passes it to this method. See
deleteDocument(int)<http://lucene.apache.org/java/docs/api/org/apache/lucene/index/IndexReader.html#deleteDocument%28int%29>for
 information about when this deletion will become effective.



From observation in my app, it is deleting documents that don't have the
provided term, which means there's no easy way to delete a doc (other than
iterating) even if you have a unique id.

On 10/15/06, Otis Gospodnetic <[EMAIL PROTECTED]> wrote:
>
> The javadoc is right. :)
>
> Otis
>
> ----- Original Message ----
> From: EDMOND KEMOKAI <[EMAIL PROTECTED]>
> To: java-user@lucene.apache.org
> Sent: Sunday, October 15, 2006 12:49:21 AM
> Subject: IndexReader.deleteDocuments
>
> Hi guys,
> I am a newbee so excuse me if this is a repost. From the javadoc it
> seems
> Reader.deleteDocuments deletes only documents that have the provided
> term,
> but the implementation examples that I have seen and from the behaviour
> of
> my own app, deleteDocuments(term) deletes documents that don't have the
> given term. Can someone clarify this for me?
>
> Thanks
> Edmond Kemokai.
>
>
> "talk trash and carry a small stick."
> PAUL KRUGMAN (NYT)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)




--
   * "Still searching for the gatekeeper to the Valence-Band, let me out of
here!"

   * "When I was coming up, it was a dangerous world, and you knew exactly
who they were. It was us versus them, and it was clear who them was. Today,
we are not so sure who the they are, but we know they're there."

          Poet Laureate G.W Bush (I am not a Bush basher by the way)

"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)

Reply via email to