Solr fq filter query examples

The fq filter query parameter in a query to Solr search is used to filter out some documents from the search result without influencing the score of the returned documents. Queries with fq parameters are cached. Any subsequent queries with the same fq paramters will hit the cache and the results will be returned faster. The fq parameter can be specified in the reauestHandler in the solrconfig.xml or it can be incorporated directly into the query.

The fq in this requestHandler will be appended to the incoming query. These filters will make sure the returned documents are in stock, and no docuemnt with ids equal to EUR, or GBP or SP2514N or 20 to 30 inclusive. The minus sign means not to include those ids. The [20 TO 30] means ids from 20 to 30 inclusive, both letters of TO have to be capital letters.

<requestHandler name="/select" class="solr.SearchHandler">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <int name="rows">10</int>
   <str name="df">text</str>
 </lst>
 <lst name="appends">
 	<str name="fq">inStock:true AND -id:(EUR OR GBP OR SP2514N OR [20 TO 30])</str>
 </lst>
</requestHandler>

The same fq parameter as the above, but incorporated the fq inside the query directly.

http://localhost:8983/solr/collection1/select?q=*:*&fq=inStock:true+AND+-id:(EUR+OR+GBP+OR+SP2514N+OR+[20+TO+30])&wt=xml

Search within Codexpedia

Custom Search

Search the entire web

Custom Search