solr:如何加入三个核心?

时间:2018-09-18 06:35:25

标签: apache solr lucene

我正在尝试根据两个相关内核上的条件在一个内核上进行查询,但没有得到任何结果。每个单独的连接都可以正常工作。

我应该如何基于两个核心来表达要加入的查询?

在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":{},

1 个答案:

答案 0 :(得分:0)

如果要使用嵌套查询,则应更正查询中的错误。 固定查询:

{!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/