lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Filter Field.Keyword possible?
Date Sun, 26 Feb 2006 11:37:51 GMT

On Feb 26, 2006, at 5:38 AM, Samuru Jackson wrote:

> Hi to all!
>
> I added some documents to my index repository this way:
>
> Document document = new Document();
> document.add(Field.Keyword("id", id));
> document.add(Field.Keyword("type", type));
> document.add(Field.Text("content", content));
>
>
> Is it possible to search only within a specific Field.Keyword? For  
> example I
> want to search only the contents that have got a Keyword  
> *type*="webpages".
>
> Is there a way to create such a filter?

Two ways....

	1) Simply create a BooleanQuery with one clause a TermQuery for  
"type" and the constraint

	2) Use a QueryFilter with that same TermQuery, and apply that Filter  
to your search method.

#1 is the simplest and most recommended to begin with unless you have  
other reasons to go to #2.

	Erik


---------------------------------------------------------------------
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