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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
"In a world without fences and walls, who needs Gates and Windows?"