首页 > 解决方案 > Solr 6 - 使用子查询/连接查询多个子文档

问题描述

我正在尝试使用来自子文档查询之一的字段值作为第二/第三个子文档查询的输入,对子文档运行父查询。

下面是一个索引示例:

[
  {
"id":1,
"title":"good",
"content_type":"parent",
"_childDocuments_":[
{
"id":"1_1",
"type":"color",
"value":"orange",
"start":"2015-01-03T14:32:00Z",
"end":"2015-01-03T14:34:00Z"
},
{
"id":"1_2",
"type":"shape",
"value":"square",
"start":"2015-01-03T14:32:00Z",
"end":"2015-01-03T14:34:00Z"
}
]
},
{
"id":2,
"title":"bad",
"content_type":"parent",
"_childDocuments_":[
{
"id":"2_1",
"type":"color",
"value":"orange",
"start":"2015-01-03T14:32:00Z",
"end":"2015-01-03T14:34:00Z"
},
{
"id":"2_2",
"type":"shape",
"value":"square",
"start":"2015-01-03T14:35:00Z",
"end":"2015-01-03T14:37:00Z"
}
]
}
]

我要做的是查询在时间范围内重叠的“color:orange”和“shape:square”的实例,并返回发生这种情况的父文档。在上面的例子中,我只希望文档 1 返回。

我尝试了很多查询,这是我认为可能最接近的查询,但仍返回 0 个结果:

{!parent which="content_type:parent"}type:color AND value:orange AND start:{!join from=start to=start}type:shape AND value:square

我知道日期位没有解决,就重叠范围而言,我只是想在遇到日期问题之前证明这个概念。

提前致谢。

标签: solr

解决方案


推荐阅读