Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The following page has been changed by HossMan: http://wiki.apache.org/solr/CommonQueryParameters The comment on the change is: some URL escaping mistakes, missleading/redundent statements ------------------------------------------------------------------------------ [[Anchor(fq)]] == fq == + - "fq" stands for filter query. + "fq" stands for Filter Query. - This parameter can be used to specify a raw lucene query that can be used to restrict the super set of documents that can be returned, without influence score. It can be very useful for speeding up complex queries since they queries specified with fq are cached independently from the main query. + + This parameter can be used to specify a [:SolrQuerySyntax: query] that can be used to restrict the super set of documents that can be returned, without influence score. It can be very useful for speeding up complex queries since they queries specified with fq are cached independently from the main query. NOTE: + 1. The fq param can be specified multiple times. Documents will only be included in the result if they are in the intersection of the document sets resulting from each fq. In the example below, only documents which have a popularity greater then 10 and have a section of 0 will match. {{{ - 1. This param '''can be specified multiple times''' - {{{ - fq=popularity:[10 TO *]&fq=section:0 + fq=popularity:[10 TO *] + & fq=section:0 }}} + 1. Filter Queries can be complicated boolean queries, so the above example could also be written as a single fq with two mandatory clauses...{{{ - - 2. The filters are '''additive''' - {{{ - fq=+popularity:[10 TO *] +section:0 + fq=+popularity:[10 TO *] +section:0 }}} + 1. Because the document sets from each filter query are cached independently. Considering the previous examples: one would want to use a single fq containing two mandatory clauses if those clauses appeared together often, and two separate fq params if they were relatively independent. + 1. As will all parameters: when expressed in a URL, special characters need to be [:SolrQuerySyntax#urlescaping: properly URL escaped]. - A single fq value of - '''{{{+popularity:[10 TO *] +section:0}}}''' is equivalent to two instances of fq with the values '''{{{popularity:[10 TO *]}}}''' and '''{{{section:0}}}'''. - - 3. A single fq can contain multiple filter (aka. '''Pay attention to the space in filter content''') - - The filter can be specified by single fq - {{{ - fq=+popularity:[10+TO+*] +section:0 - - fq=+popularity:[10%20TO%20*]%20+section:0 - }}} - Both fq param is valid. - The ''+'' or ''%20'' in the example above meaning '''escaped space''', please keep it in the Request when you applying multiple filter. - However, when '''you want your filter contain space''', you need to "quote" the filter before you put them into the request header: - {{{ - +name:"jack smith" +section:0 - +name:"Joe smith" +section:0 - +name:"lee harvey" +section:0 - }}} - more information please see discussion on "Multiple fq fields in URL" (http://www.nabble.com/Multiple-fq-fields-in-URL-td10334495.html) - - 4. fq's are '''cached independently''', so for best efficiency, one would want to use the former if those clauses appeared together often, and the latter if they were relatively independent. - [[Anchor(fl)]] == fl ==
