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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to