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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to