Someone please give me a decent explanation of the difference between q and fq in Solr query, covering some points such as -
- Do they have the same syntax?
- Do they return same results?
- When to use which one and why?
- Any other differences
Someone please give me a decent explanation of the difference between q and fq in Solr query, covering some points such as -
Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter.
The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).
The q parameter takes your query and execute against the index. Then you can use filter queries (can use multiple filter queries) to filter the results.
For example your query can look like this.
q=author:shakespeare
this will match the documents which has 'shakespeare' in the 'author' field. Then you can use filter queries like this.
fq=title:hamlet
fq=type:play
Those will filter the results based on the other fields. You can even filter on the same field.
The query syntax is similar for both q and fq parameters