solr:如何加入三个核心?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了solr:如何加入三个核心?相关的知识,希望对你有一定的参考价值。
我正在尝试根据两个相关内核的条件查询核心但我没有得到任何结果。每个单独的连接工作正常。
我应该如何基于两个核心来表达要加入的查询?
在SQL世界中,这称为内连接,有三个表来获取交集。
SQL对应:
SELECT *
FROM proddev
INNER JOIN department ON HMProductDevelopmentDepartment==id
INNER JOIN season ON HMProductDevelopmentSeason==id
我正在运行solr-7.3.1。查询在http://localhost:8983/solr/#/proddev/query中执行
{!join from=id fromIndex=season to=HMProductDevelopmentSeason}name:"8-2018" AND _query_ {!join from=id fromIndex=department to=HMProductDevelopmentDepartment}DepartmentNumber:6515
主要表:proddev
{
"id":"48352.32064.2208.65165",
"name":["0439370D"],
"HMProductDevelopmentDepartment":["48352.32064.61248.42035"],
"HMProductDevelopmentSeason":["48352.32064.24988.33959"],
"HMCandidateForFileSync":[" FALSE "],
"PublishedDate":[" 11/14/2017 11:29:25 AM "],
...
}
相关核心:赛季
{
"id":"48352.32064.24988.33959",
"name":["8-2018"],
"_version_":1611866808030068736,
"name_str":["8-2018"]}]
}
相关核心:部门
{
"id":"48352.32064.61248.42035",
"name":["448"],
"DepartmentNumber":[" 6515"],
"_version_":1611923411375751168,
"name_str":["448"],
"DepartmentNumber_str":[" 6515"]}]
}
调试响应:
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"{!join from=id fromIndex=season to=HMProductDevelopmentSeason}name:"8-2018" AND _query_ {!join from=id fromIndex=department to=HMProductDevelopmentDepartment}DepartmentNumber:6515",
"debugQuery":"on",
"_":"1537194871447"}},
"response":{"numFound":0,"start":0,"docs":[]
},
"debug":{
"rawquerystring":"{!join from=id fromIndex=season to=HMProductDevelopmentSeason}name:"8-2018" AND _query_ {!join from=id fromIndex=department to=HMProductDevelopmentDepartment}DepartmentNumber:6515",
"querystring":"{!join from=id fromIndex=season to=HMProductDevelopmentSeason}name:"8-2018" AND _query_ {!join from=id fromIndex=department to=HMProductDevelopmentDepartment}DepartmentNumber:6515",
"parsedquery":"JoinQuery({!join from=id to=HMProductDevelopmentSeason fromIndex=season}+name:"8 2018" +_text_:_query_ {!join from=id to=HMProductDevelopmentDepartment fromIndex=department}DepartmentNumber:6515)",
"parsedquery_toString":"{!join from=id to=HMProductDevelopmentSeason fromIndex=season}+name:"8 2018" +_text_:_query_ {!join from=id to=HMProductDevelopmentDepartment fromIndex=department}DepartmentNumber:6515",
"explain":{},
答案
如果要使用嵌套查询,则应修复查询中的错误。固定查询:
{!join from=id fromIndex=season to=HMProductDevelopmentSeason}name:"8-2018" AND _query_:"{!join from=id fromIndex=department to=HMProductDevelopmentDepartment}DepartmentNumber:6515"
或者您可以使用筛选查询进行第二次连接。
链接: https://lucidworks.com/2009/03/31/nested-queries-in-solr/
以上是关于solr:如何加入三个核心?的主要内容,如果未能解决你的问题,请参考以下文章
solr分布式索引实战分片配置读取:工具类configUtil.java,读取配置代码片段,配置实例
如何使用SOLRJ java客户端从SOLR获取列名(字段)?