Difference between q and fq in Solr

核能气质少年 提交于 2020-06-11 16:47:26

问题


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

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/20988516/difference-between-q-and-fq-in-solr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!