lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vinicius Carvalho" <viniciusccarva...@gmail.com>
Subject Re: Termdocs question
Date Mon, 23 Jun 2008 13:56:00 GMT
I'm sorry, the problem was with the way the id was being indexed. It was
marked as tokenized, so I when searched for it's untokenized form I was not
getting the doc, now everything works fine :)

Regards

On Sat, Jun 21, 2008 at 2:08 PM, Karl Wettin <karl.wettin@gmail.com> wrote:

>
> 20 jun 2008 kl. 18.12 skrev Vinicius Carvalho:
>
>
>  Hello there! I trying to query for a specific document on a efficient way.
>>
>
> Hi Vinicius,
>
>            termDocs = reader.termDocs(term);
>>           while(termDocs.next()){
>>               int index = termDocs.doc();
>>               if(reader.document(index).get("id").equals(id)){
>>                   reader.deleteDocument(index);
>>               }
>>           }
>>
>
> Iterating documents and string comparing stored values is not very
> efficient. Use a query instead, something like this:
>
> BooleanQuery query = new BooleanQuery();
> query.add(new TermQuery(term), Occurs.MUST);
> query.add(new TermQuery(new Term("id", id), Occurs.MUST);
> searcher.search(query, new HitCollector() {
>  public void collect(int doc, float score) {
>    reader.deleteDocument(doc);
>  }
> });
>
>
>       karl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
"In a world without fences and walls, who needs Gates and Windows?"

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message