Mawia
Mawia

Reputation: 4310

Difference between q and fq in Solr

Someone please give me a decent explanation of the difference between q and fq in Solr query, covering some points such as -

Upvotes: 24

Views: 19427

Answers (2)

Sapumal Jayaratne
Sapumal Jayaratne

Reputation: 169

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

Upvotes: 10

jro
jro

Reputation: 7480

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).

Upvotes: 24

Related Questions