solr 主查询 vs fq [英] solr main query vs fq

查看:32
本文介绍了solr 主查询 vs fq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了同一问题的所有答案,但对于我的用例应该使用哪个答案以及原因并不清楚.两者都返回相同的结果.我知道FilterQuery 将被缓存,使整体查询时间更快",就像有人正确回答一样.

I read all answers to the same question and am not any clearer on which one I should use for my usecase and why. Both return the same result. I understand that "FilterQuery would be cached making the overall query time faster", like someone correctly answered.

我也明白过滤还允许标记方面,因此您可以标记方面以包括为您的查询返回的所有方面",就像其他人也正确回答一样.

I also understand that "filtering also allows tagging of facets, so you can tag facets to include all facets that are returned for your query", like someone else also correctly answered.

阅读本文时我不明白为什么有人会使用 Q,因为根据我看过的所有答案和书籍,FQ 似乎要好得多.

What I don't understand reading this, is why then anyone would use Q, since FQ seems to be so much better, based on all the answers and books I've seen.

除此之外,我确定两者存在可能是有原因的.

Except, I'm sure there's probably a reason that both exist.

我想弄清楚什么最适合我的用例 - 文档非常缺乏有用的示例.

What I would like is to figure out what's best for my use case - the documentation is sorely lacking in useful examples.

  • 我的文档有:日期、客户、报告和其他一些字段
  • 1 个工作日 = 350 万份文档.
  • 文档总数为 2.5 亿,并且还在不断增加(60 个日期 * 8000 个客户 * 1000 份报告)
  • 我对日期、客户、报告进行了分面,并且我确实使用了方面的标记.
  • UI 整体看起来像任何电子商务网站,例如:亚马逊,左侧有多个方面.
  • 不使用评分.

业务规则 #1:日期必须始终出现在每个查询中.

Business rule #1: date must always be present in every query.

业务规则 #2:99% 的查询将使用最新日期,但使用 RANDOM 客户端和随机报告.

Business rule #2: 99% of queries are going to use the LATEST date, but RANDOM client and random report.

事实:我们确定它的分面是缓慢的,而不是搜索.

A Fact: We determined that it’s faceting that is slow, not searching.

问题:

给定这个搜索条件,以及编写查询的这些方法:

Given this search criteria, and these ways to write a query:

A) q=date:20130214 AND 客户:Joe &facet.field=date &facet.field=客户端...

A) q=date:20130214 AND client:Joe & facet.field=date & facet.field=client...

B) q=日期:20130214 &fq=客户:乔&facet.field=date &facet.field=客户端...

B) q=date:20130214 & fq=client:Joe & facet.field=date & facet.field=client...

C) q=client:Joe &fq= 日期:20130214 &facet.field=date &facet.field=客户端...

C) q=client:Joe & fq= date:20130214 & facet.field=date & facet.field=client...

D) q=*:* &fq=日期:20130214 &fq=客户:乔&facet.field=date &facet.field=客户端...

D) q=*:* & fq=date:20130214 & fq=client:Joe & facet.field=date & facet.field=client...

  • 您认为以上哪一项最好,为什么?请记住,大多数查询都将针对 20130214
  • 先进行 FQ 过滤,然后应用 Q 条件,还是反过来?

今天,我在所有情况下都使用了 D),但我怀疑这是错误的,并且会导致 Solr(3.6 版)出现 OOM.

Today, I have D) is used in all cases, but I suspect this is wrong and is causing OOMs in Solr(version 3.6).

感谢您的帮助!

推荐答案

q 查询是请求的主要查询.
它允许您实际搜索多个字段.
q 查询将决定每个文档的得分,因此将参与相关性计算.

q query is the main query of the Request.
It is the one that would allow you to actually search over multiple fields.
q query would decide what score each of the documents has and hence would take part in the relevancy calculation.

q=*:* 只会返回分数相同的所有文档.

q=*:* will just return all the documents with the same score.

fq 是用于过滤文档的过滤查询,与搜索无关.
因此,如果您有任何要过滤的固定值,则应使用过滤器来限制结果.
fq 不影响结果的评分.
在过滤时,Solr 使用过滤器缓存来增强后续过滤器查询的性能.

fq is the filter query used to filter the documents and is not related to search.
So if you have any fixed value which you want to filter on you should use filters to limit your results.
fq does not affect the scoring of the results.
While filtering, Solr uses Filter cache to enhance the performance for the subsequent filter queries.

因此,理想情况下,您应该检查需求的要求.如果你想搜索,你应该总是使用q,如果你想过滤/限制结果,你应该使用fq.

So ideally, you should check what the requirement demands. If you want to search, you should always use q, and if you want to filter/limit results you should use fq.

Facets 只是结果的附加组件,不会影响您的结果.

Facets are just an add-on to the results and do not affect your results.

这篇关于solr 主查询 vs fq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆