Re: Deleting a document found in a search
You mean d.get(Id); ? Otis --- [EMAIL PROTECTED] wrote: I am just getting started with Lucene and I think I have a problem understanding some basic concepts. I am using two-part identifiers to uniquely identify a document in the index. So whenever I want to index a document, I first want to find and delete the old form. To find it, I intend to use: BooleanQuery findOurs = new BooleanQuery(); findOurs.add(new TermQuery(new Term(Id, id)), true, false); findOurs.add(new TermQuery(new Term(Domain, domain)), true, false); System.out.println(Deleting document matching: \ + findOurs.toString() + ''); Searcher searcher = new IndexSearcher(directory); Hits hits = searcher.search(findOurs); // Assert: hits.length() = 1 for (int i = 0 ; i hits.length() i 10; i++) { Document d = hits.doc(i); // Now what can I do to find document id? int id = ?? searcher.delete(id); } But I can't discover how to convert a search result into a document id. It is recorded in the private HitDoc class, but since it is not publicly accessible, there must be a reason why it would not work to add a public getter for it. Is there an alternative way that I can do this? My first thought is to define a Field.Keyword(composite-key, domain + \u + id). This would allow me to use the delete(Term) interface to delete the key. -- Thanks, Adrian. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Deleting a document found in a search
No, I mean HitDoc.id, the document number field stored in the HitDoc class. This number is needed when calling IndexReader.delete(int docnum) but it is not publicly accessible. -- Adrian At 06:32 09/10/2002 -0700, Otis Gospodnetic wrote: You mean d.get(Id); ? --- [EMAIL PROTECTED] wrote: I am just getting started with Lucene and I think I have a problem understanding some basic concepts. I am using two-part identifiers to uniquely identify a document in the index. So whenever I want to index a document, I first want to find and delete the old form. To find it, I intend to use: BooleanQuery findOurs = new BooleanQuery(); findOurs.add(new TermQuery(new Term(Id, id)), true, false); findOurs.add(new TermQuery(new Term(Domain, domain)), true, false); System.out.println(Deleting document matching: \ + findOurs.toString() + ''); Searcher searcher = new IndexSearcher(directory); Hits hits = searcher.search(findOurs); // Assert: hits.length() = 1 for (int i = 0 ; i hits.length() i 10; i++) { Document d = hits.doc(i); // Now what can I do to find document id? int id = ?? searcher.delete(id); } But I can't discover how to convert a search result into a document id. It is recorded in the private HitDoc class, but since it is not publicly accessible, there must be a reason why it would not work to add a public getter for it. Is there an alternative way that I can do this? My first thought is to define a Field.Keyword(composite-key, domain + \u + id). This would allow me to use the delete(Term) interface to delete the key. -- Thanks, Adrian. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Deleting a document found in a search
[EMAIL PROTECTED] wrote: My first thought is to define a Field.Keyword(composite-key, domain + \u + id). This would allow me to use the delete(Term) interface to delete the key. That sounds like a good way to solve this. You could also use a HitCollector with a Query, but I think the composite key is a better approach. Doug -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]