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 "Stephan J. Schmidt" <st...@neotis.de> on 2001/12/19 16:17:53 UTC

Deleting problem

Hi,

I have problems deleting documents from the index.
The documents are indexed with an unique OID. Searching
for this OID returns some documents but deleting
this OID returns 0 for deleted documents.

      Searcher searcher = new IndexSearcher("/opt/server/neotis/solent/kindex");

      String oidString = "E78180808080808080808080808080neotis";
      Query query = QueryParser.parse(oidString, "OID", new OIDAnalyzer());

      Hits hits = searcher.search(query);

      int start = 0;
      final int HITS_PER_PAGE = 10;
      int end = Math.min(HITS_PER_PAGE, hits.length());

      // Documents are found here      
      for(int i = start; i < end; i++) {
        System.out.println(hits.doc(i).get("Name")+" OID:"+hits.doc(i).get("OID"));
      }
     
      searcher.close();

      // Returns "0" for deleted documents and documents are not deleted 
      IndexReader reader = IndexReader.open("/opt/server/neotis/solent/kindex");
      System.err.println("Deleted: " + reader.delete(new Term("OID", oidString)))

Thanks,
bye
-stephan


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Deleting problem

Posted by Mike Baroukh <mb...@cardiweb.com>.
Hi.

Maybe it's the same problem that I asked for and Otis Gospodnetic has just
answered (Many thanks !) :

If your analyzer convert tokens to lower case, then you must use lower case
value to search with IndexReader.
You can see it with TermEnum and look at values taht are really stored in
the index ...


----- Original Message -----
From: "Stephan J. Schmidt" <st...@neotis.de>
To: <lu...@jakarta.apache.org>
Sent: Wednesday, December 19, 2001 4:17 PM
Subject: Deleting problem


> Hi,
>
> I have problems deleting documents from the index.
> The documents are indexed with an unique OID. Searching
> for this OID returns some documents but deleting
> this OID returns 0 for deleted documents.
>
>       Searcher searcher = new
IndexSearcher("/opt/server/neotis/solent/kindex");
>
>       String oidString = "E78180808080808080808080808080neotis";
>       Query query = QueryParser.parse(oidString, "OID", new
OIDAnalyzer());
>
>       Hits hits = searcher.search(query);
>
>       int start = 0;
>       final int HITS_PER_PAGE = 10;
>       int end = Math.min(HITS_PER_PAGE, hits.length());
>
>       // Documents are found here
>       for(int i = start; i < end; i++) {
>         System.out.println(hits.doc(i).get("Name")+"
OID:"+hits.doc(i).get("OID"));
>       }
>
>       searcher.close();
>
>       // Returns "0" for deleted documents and documents are not deleted
>       IndexReader reader =
IndexReader.open("/opt/server/neotis/solent/kindex");
>       System.err.println("Deleted: " + reader.delete(new Term("OID",
oidString)))
>
> Thanks,
> bye
> -stephan
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Deleting problem

Posted by Otis Gospodnetic <ot...@yahoo.com>.
I'm not sure if you got an answer to your question nor whether this is
going to be a correct answer, but have you tried calling isDeleted() on
those documents that you are printing out in that for loop?  Could it
be that they are already deleted?
What happens if you optimize the index first and then run this code?

Otis


--- "Stephan J. Schmidt" <st...@neotis.de> wrote:
> Hi,
> 
> I have problems deleting documents from the index.
> The documents are indexed with an unique OID. Searching
> for this OID returns some documents but deleting
> this OID returns 0 for deleted documents.
> 
>       Searcher searcher = new
> IndexSearcher("/opt/server/neotis/solent/kindex");
> 
>       String oidString = "E78180808080808080808080808080neotis";
>       Query query = QueryParser.parse(oidString, "OID", new
> OIDAnalyzer());
> 
>       Hits hits = searcher.search(query);
> 
>       int start = 0;
>       final int HITS_PER_PAGE = 10;
>       int end = Math.min(HITS_PER_PAGE, hits.length());
> 
>       // Documents are found here      
>       for(int i = start; i < end; i++) {
>         System.out.println(hits.doc(i).get("Name")+"
> OID:"+hits.doc(i).get("OID"));
>       }
>      
>       searcher.close();
> 
>       // Returns "0" for deleted documents and documents are not
> deleted 
>       IndexReader reader =
> IndexReader.open("/opt/server/neotis/solent/kindex");
>       System.err.println("Deleted: " + reader.delete(new Term("OID",
> oidString)))
> 
> Thanks,
> bye
> -stephan
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>