lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Adding filter in custom query parser
Date Wed, 01 Oct 2014 17:30:05 GMT

: For eg : "red shirt under 20$" should be translated to q=shirt&fq=price:[*
: TO 20] and possibly apply color to one the attribute of doc index.
: in parser overrided method, how can i add the filter and pass the query
: back?

I don't think you can acomplish this just within the QParser API ... it's 
really designed to produce a single Query, and might be used from multiple 
contexts (ie: how would your custom parser behave if i tried to use it in 
a facet.query?

Your best approach would probably be to implement a SearchComponent.

Either subclass QueryComponent and overriding where the q param is 
passed to the default QParser, or by writting a standalone component that 
comes first in the chain and ripping apart the q param before 
QueryComponent ever sees it.

you can add your programatic filters via ResponseBuilder.setFilters() and 
use ResponseBuilder.setQueryString() to leave whatever remaining user 
input you want for QueryComponent to parse using the appropriate QParser.

the standalone SerachComponent route is probably the most straight 
forward and easiest to maintain.


View raw message