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 + "\u0000" + 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]>