Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 3515 invoked from network); 23 Jun 2008 13:56:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jun 2008 13:56:37 -0000 Received: (qmail 27623 invoked by uid 500); 23 Jun 2008 13:56:32 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 27591 invoked by uid 500); 23 Jun 2008 13:56:31 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 27575 invoked by uid 99); 23 Jun 2008 13:56:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2008 06:56:31 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of viniciusccarvalho@gmail.com designates 64.233.166.181 as permitted sender) Received: from [64.233.166.181] (HELO py-out-1112.google.com) (64.233.166.181) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2008 13:55:42 +0000 Received: by py-out-1112.google.com with SMTP id z74so995776pyg.9 for ; Mon, 23 Jun 2008 06:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=HarJtGkikkwarCV/FXIyihlMpq8UPQq/wjx8du2Lu1o=; b=VUvD7Q6/KjHEtUPZ1Ye5kGkSzyJL0VySClEzC0SWA56Uz8qyE4bllSiZx75/L5bocP LQ2onMkMzt5uA/M7Im1Gr700xFD3vAXcFAIR1jWi0c5OUHEineWVcMLskclL2l2zUJT8 NqBt4Tuc8a0wXagzv6oOKfAoBrlz0oBCD44VU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=N7XmFKhpHr2eimQuTXbtODNsgiXxtUqoi0mOmAqu2yXw3CEE4c/uiXn2KqxF2agcea CGi/ea+sOfyM8YsWy+xyn+S6ylZeyQ2UMONoPZ/YgCK9vWBLhz1c+H/ZTPAoXb0IR9lq SgMIemXnlbNYiQLn53bfgMeVxLXf0Y06UXffI= Received: by 10.143.37.20 with SMTP id p20mr3795515wfj.236.1214229360211; Mon, 23 Jun 2008 06:56:00 -0700 (PDT) Received: by 10.114.132.18 with HTTP; Mon, 23 Jun 2008 06:56:00 -0700 (PDT) Message-ID: <9d2777b60806230656q5484d6fekabd217e1dee352d4@mail.gmail.com> Date: Mon, 23 Jun 2008 10:56:00 -0300 From: "Vinicius Carvalho" To: java-user@lucene.apache.org Subject: Re: Termdocs question In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16218_18637233.1214229360207" References: <9d2777b60806200912k153d17f1y81b62050d8c401f4@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_16218_18637233.1214229360207 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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?" ------=_Part_16218_18637233.1214229360207--