lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Deleting a document found in a search
Date Wed, 09 Oct 2002 13:32:25 GMT
You mean d.get("Id"); ?

Otis

--- lucene.user@ajm.co.nz 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 + "\u0000" + id). 
> This
> would allow me to use the delete(Term) interface to delete the key.
> 
> -- 
> Thanks, Adrian.
> 
> --
> To unsubscribe, e-mail:  
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:lucene-user-help@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message