lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markharw00d <markharw...@yahoo.co.uk>
Subject Re: Is there a FilterQueryParser?
Date Tue, 18 Sep 2007 22:25:38 GMT
Scott Tiger wrote:
> I want get BooleanFilter contains two RangeFilters from query string.
>   
The XMLQueryParser may be of interest.
See BooleanFilter.xml and CachedFilter.xml examples in the 
XMLQueryParser Junit tests.

I typically use QueryTemplateManager to transform user input provided in 
a form using a stylesheet encapsulating the query/filtering logic. See 
TestQueryTemplateManager Junit test for an example. Criteria like dates 
and price ranges typically have structured fields in forms and get 
mapped to RangeFilters in the query template. Structured fields with 
limited options for values (e.g. status:draft/published) are ideal 
candidates for surrounding with the <CachedFilter> tag to improve 
performance.  Form fields that allow standard Lucene query syntax can be 
mapped to a <UserQuery> tag for processing.

Cheers
Mark


> Can I use FilterQuery to get RangeFilter?
>
> example:
>
> my query string:
>
>   field1:[0 TO 100] AND field2:[1000 TO 2000]
>
> BooleanFilter I want:
>   BooleanFilter bf = new BooleanFilter();
>   bf.add(
>     new FilterClause(
>       new RangeFilter("field1","0", "100", true, true),
>       BooleanClause.Occur.MUST
>     )
>   );
>   bf.add(
>     new FilterClause(
>       new RangeFilter("field2", "1000", "2000", true, true),
>       BooleanClause.Occur.MUST
>     )
>   );
>
> QueryFilter example:
>   QueryParser qp = new QueryParser("", new KeywordAnalyzer());
>   Query query = qp.parse("field1:[0 TO 100] AND filed2:[1000 TO 2000]");
>   Filter filter = new CachingWrapperFilter(new QueryWrapperFilter(query));
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
>   



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