如何在 Solr 中 OR 两个连接 [英] How to OR two joins in Solr
问题描述
我有以下声明:
({!join from=project_uuid to=id}type:EM_PM_Timerecord AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z]) OR ({!join from=project_uuid to=id}type:EM_CM_Request_Member AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z])
它不返回任何文件,但如果我只使用其中一个连接,例如:
It doesn't return any documents, but if I use only one of the joins e.g.:
{!join from=project_uuid to=id}type:EM_PM_Timerecord AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z]
它返回一些文档.
如果我删除日期范围,它也能正常工作:
If I remove the date ranges it works as well:
({!join from=project_uuid to=id}type:EM_PM_Timerecord) OR ({!join from=project_uuid to=id}type:EM_CM_Request_Member)
有人能告诉我我错过了什么吗?第一个陈述有什么问题?
Can someone tell me what I'm missing? And what is wrong with the first statement?
提前致谢.
编辑
在调试中解析的查询如下所示:
In debug the parsed query looks like this:
(+JoinQuery({!join from=project_uuid to=id}type:EM_PM_Timerecord) +created:[1420074000000 TO 1451610000000]) (+JoinQuery({!join from=project_uuid to=id}type:EM_CM_Request_Member) +created:[1420074000000 TO 1451610000000])
也许我应该提到我将它用作过滤查询,但据我所知,这不会对结果产生影响.
And maybe I should mention that I use it as a filter query, but as far as i understand it that should not make a difference in the result.
推荐答案
我现在按照建议在 SolrUsers 邮件列表中询问,我得到了答案.
I asked now in the SolrUsers mailing list as recommended and I got an answer.
必须将查询拆分为多个查询,如下所示:
The query has to be split up in multiple queries like this:
&q={!join from=project_uuid to=id v=$q1} OR {!join from=project_uuid to=id v=$q2}
&q1=type:EM_PM_Timerecord AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z]
&q2=type:EM_CM_Request_Member AND created:[2015-01-01T01:00:00Z TO 2016-01-01T01:00:00Z]
它工作正常.
我的问题是我把整个事情放在 &q=... 下,显然这太多了.
My problem was that I put the whole thing under &q=... and apparently that was to much.
这篇关于如何在 Solr 中 OR 两个连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!