Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 55009 invoked from network); 26 Oct 2005 17:55:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Oct 2005 17:55:27 -0000 Received: (qmail 31246 invoked by uid 500); 26 Oct 2005 17:55:19 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 31200 invoked by uid 500); 26 Oct 2005 17:55:19 -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 31167 invoked by uid 99); 26 Oct 2005 17:55:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Oct 2005 10:55:19 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [169.229.70.167] (HELO rescomp.berkeley.edu) (169.229.70.167) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Oct 2005 10:55:15 -0700 Received: by rescomp.berkeley.edu (Postfix, from userid 1007) id 58F575B7CC; Wed, 26 Oct 2005 10:54:54 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by rescomp.berkeley.edu (Postfix) with ESMTP id 564127F471 for ; Wed, 26 Oct 2005 10:54:54 -0700 (PDT) Date: Wed, 26 Oct 2005 10:54:54 -0700 (PDT) From: Chris Hostetter Sender: hossman@hal.rescomp.berkeley.edu To: java-user@lucene.apache.org Subject: Re: FilteredQuery usage In-Reply-To: <1130328901.26521.18.camel@aris.si.uji.es.si.uji.es> Message-ID: References: <1130328901.26521.18.camel@aris.si.uji.es.si.uji.es> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N : filter, I need to query all the index checking if the value of field : name "path" is a prefix or not. : : There's a way to do that query without having to retrieve all the : Document instances from the index? Yep, you're definitely on the right track. You don't need to retrieve any documents at all, you just need to look at all of hte indexed terms in your field, and find the ones that match your prefix. I would start by trying to write a Filter that only deals with one prefix (not an array of prefixes) and when you get that working, then you can then combine several of them using a ChainedFilter, or expand your filter to opperate on an array/set of prefixes instead. Start by taking a look at the way RangeFilter works for an example of how to use a TermEnum and a TermDocs to collect the list of documentIds that have values indexed between two terms. The main difference between what you want to do, and what is done in RangeFilter, is that instead of looking for all terms between "a" and "b" you want to look for all terms between "a" and the first subsequent term that does not have "a" as a prefix. http://svn.apache.org/viewcvs.cgi/lucene/java/trunk/src/java/org/apache/luc= ene/search/RangeFilter.java?rev=3D150665&view=3Dmarkup : : public class PrefijoURLFilter extends Filter : { : private String field; : private String[] prefix; : : public PrefijoURLFilter(String field, String[] prefix) : { : this.field =3D field; : this.prefix =3D prefix; : } : : public BitSet bits(IndexReader reader) throws IOException : { : BitSet bits =3D new BitSet(reader.maxDoc()); : : =09//FOR EACH PREFIX AND FOR EACH DOCUMENT IN INDEX CHECK IF : =09//STARTS WITH A VALID PREFIX AND SET IT IN THE BITSET : : return bits; : } : } : : : A valid usage of this filter could be: : : filter =3D new PrefijoURLFilter("path", new String[] { : =09"http://xxx/CA/noticies/agenda/", : =09"http://xxx/noticies/agenda/", : =09"http://xxx/CA/content/agenda/", : =09"http://xxx/content/agenda/" : }); : : Thanks a lot!!! : : -- : Salut, : =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D : Ricardo Borillo Domenech : Analista/Programador - Servei d'Inform=E0tica : Universitat Jaume I : http://xml-utils.com : -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org