Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOLR filter-query vs main-query

Tags:

filter

solr

SOLR docs, state that filter queries, unlike the main query, do not influence the document score. Can anyone explain what does this mean exactly, preferably with an example.

Thanks.

like image 965
mrd3650 Avatar asked Jan 04 '12 17:01

mrd3650


People also ask

What is filter query in Solr?

Solr provides Query (q parameter) and Filter Query (fq parameter) for searching. The query (q parameter), as the name suggests, is the main query used for searching. Example. q = title:james. Filter queries are used alongside query (q parameter) to limit results of queries using additional filters.

How do I query in Solr collection?

You can search for "solr" by loading the Admin UI Query tab, enter "solr" in the q param (replacing *:* , which matches all documents), and "Execute Query". See the Searching section below for more information. To index your own data, re-run the directory indexing command pointed to your own directory of documents.

What is the default return type of Solr request?

The default value is 0 . In other words, by default, Solr returns results without an offset, beginning where the results themselves begin.

What are wildcard search parameters Solr?

Wildcard Searches The wildcard search: tes* would match test, testing, and tester. You can also use wildcard characters in the middle of a term. For example: te*t would match test and text. *est would match pest and test.


1 Answers

A FilterQuery ONLY stores document IDS. This makes it very fast to apply the filter to include/exclude documents. Good examples of this are when filtering products from search based on Country, Product Type, Availability, etc.

A normal query can perform the exact same function, but it has a very complex scoring system to determine "relevance". I believe the documentation is indicating that scoring is only done on the Main Query, not on the Filter Query. This should also increase query speed.

So, I can query for:

description:Kohler AND productType:Toilet 

Or I can query for:

description:Kohler with a FQ of productType:Toilet 

The results would be the same, but the scores would be different. Also, if you get many different queries throughout the day that are for productType:Toilet, the FilterQuery would be cached making the overall query time faster.

like image 110
rfeak Avatar answered Sep 22 '22 18:09

rfeak