SOLR - 如何处理 2 个多值字段之间的 AND 子句
我们如何在 SOLR 查询中在两个多值字段之间使用 AND 子句?
例如;下面是数据库表JobseekerID的图片
CompanyID Email Sent On
=========== ======================== ====
123 ; ABC 2011年7月22日
123 p; XYZ 2011年7月1日
现在在Sql中,如果我查询
Where CompanyID = "ABC" AND EmailSentOn > 2011 年 7 月 14 日(将返回 TRUE)
其中 CompanyID = "XYZ" AND EmailSentOn > 2011年7月14日(它将返回FALSE)
我们如何在SOLR中处理它?以下是我的 SOLR Collection 的图片,我如何存储数据
{int name="jobseekerid"}123{/int}
........................
. ........................................................
{ arr
name="CompanyID"}
{str}ABC{/str}
{str}XYZ{/str}
{ /arr}
{arr name="EmailSentOn"}
{str}2011-07-22T17:44:00Z{/str}
{str}2011-07-01T05:10:00Z{/str}
{/arr}
我如何在 SOLR Now 中查询 Jobseeker 123。因为对于 SOLR 来说,CompanyID 和 EmailSentON 之间没有任何关系。它们需要两个独立的实体。
当我们查询 Company ID 为“ABC”且 EmailSentOn >= 14-July-2011 时,它将返回 TRUE;当我们查询 CompanyID 为“XYZ”且 EmailSentOn >= 14-July-2011 时,它将再次返回 TRUE,因为SOLR 将查看公司 ID“XYZ”是否存在,并且“发送电子邮件”中的任何日期都大于 7 月 14 日,那么它将返回真。
但我们需要它来检查 CompanyID“XYZ”以及公司 XYZ 日期是否大于 7 月 14 日。事实并非如此,因为 XYZ 发送电子邮件的日期是“7 月 1 日”。所以它应该返回 false。
我希望你明白我的意思。谁能指导我如何在 SOLR 中处理这个问题?
How would we use AND clause in the SOLR query between 2 fields those are multiple value fields?
For example; following is the picture of database table
JobseekerID CompanyID Email Sent On
=========== =========== ==============
123 ABC 22-Jul-2011
123 XYZ 01-Jul-2011
Now in Sql, if i query
Where CompanyID = "ABC" AND EmailSentOn > 14-Jul-2011 (It will return TRUE)
Where CompanyID = "XYZ" AND EmailSentOn > 14-Jul-2011 (It will return FALSE)
How would we handle it in SOLR? Following is the picture of my SOLR Collection, how i am storing the data
{int name="jobseekerid"}123{/int}
.....................
.....................
.....................
{arr name="CompanyID"}
{str}ABC{/str}
{str}XYZ{/str}
{/arr}
{arr name="EmailSentOn"}
{str}2011-07-22T17:44:00Z{/str}
{str}2011-07-01T05:10:00Z{/str}
{/arr}
How can i query in the SOLR Now for Jobseeker 123. Because for SOLR there is not any relation between CompanyID and EmailSentON. It takes them two separate entities.
When we will query Company ID is "ABC" and EmailSentOn >= 14-July-2011 it will return TRUE and when we will say CompanyID is "XYZ" and EmailSentOn >= 14-July-2011 it will again return TRUE because SOLR will see, does company ID "XYZ" exist and any date in the 'email sent on' is greater than 14-July then it will return true.
But we need it to check if the CompanyID "XYZ" then the company XYZ date is greater than 14-july or not. Which is not, because XYZ sent email date is "01-Jul". So it should return false for that.
I hope you get my point. Can anyone please guide me how would we handle this in SOLR?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的问题在于模式的定义 - 您实际上没有多值数据!相反,您应该只有两个单独的索引文档,其中 CompanyId 和 EmailSentOn 具有单个值。然后,当您按日期搜索时,您只会返回一个或另一个文档的内容,而不会像现在那样出现混乱的结果。
The problem here is with the definition of the schema - you don't actually have multiValued data! Instead, you should just have two separate indexed documents with single values for CompanyId and EmailSentOn. Then when you search by date you get back just the contents of one document or another and don't have the results jumbled as you do now.