lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: FilteredQuery usage
Date Wed, 26 Oct 2005 17:54:54 GMT
: 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/lucene/search/RangeFilter.java?rev=150665&view=markup




:
: public class PrefijoURLFilter extends Filter
: {
:     private String field;
:     private String[] prefix;
:
:     public PrefijoURLFilter(String field, String[] prefix)
:     {
:         this.field = field;
:         this.prefix = prefix;
:     }
:
:     public BitSet bits(IndexReader reader) throws IOException
:     {
:         BitSet bits = new BitSet(reader.maxDoc());
:
: 	//FOR EACH PREFIX AND FOR EACH DOCUMENT IN INDEX CHECK IF
: 	//STARTS WITH A VALID PREFIX AND SET IT IN THE BITSET
:
:         return bits;
:     }
: }
:
:
: A valid usage of this filter could be:
:
: filter = new PrefijoURLFilter("path", new String[] {
: 	"http://xxx/CA/noticies/agenda/",
: 	"http://xxx/noticies/agenda/",
: 	"http://xxx/CA/content/agenda/",
:     	"http://xxx/content/agenda/"
: });
:
: Thanks a lot!!!
:
: --
: Salut,
: ====================================
: Ricardo Borillo Domenech
: Analista/Programador - Servei d'Informàtica
: 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


Mime
View raw message