solr嵌套文档:对父母文档的查询,该文档具有多个特定的嵌套文档
让我们想象我有几个嵌套文档的文档:
{
"id": "doc1",
"type": "maindoc",
"title": "some document 1 title"
"nested": [
{
"id": "nested1",
"nested_type": "nestedType1",
"title": "nested doc 1 title"
},
{
"id": "nested2",
"nested_type": "nestedType2",
"title": "nested doc 2 title"
},
{
"id": "nested3",
"nested_type": "nestedType3",
"title": "nested doc 3 title"
}
]
}
因此,如果我想搜索已嵌套文档1的文档 - 我要这样做:
{!parent which='type:maindoc'}
nested_type:nestedType1
但是,如果我想搜索同时有2个特定孩子的文档,该怎么办? 例如,我想找到具有NestedType1 + NestedType2的DOC。
显然,这样的查询将不起作用:
{!parent which='type:maindoc'}
nested_type:nestedType1 AND nested_type:nestedType2
那我该怎么做?这根本可能吗?
Let's imagine I have document with several nested documents:
{
"id": "doc1",
"type": "maindoc",
"title": "some document 1 title"
"nested": [
{
"id": "nested1",
"nested_type": "nestedType1",
"title": "nested doc 1 title"
},
{
"id": "nested2",
"nested_type": "nestedType2",
"title": "nested doc 2 title"
},
{
"id": "nested3",
"nested_type": "nestedType3",
"title": "nested doc 3 title"
}
]
}
So now if I want to search for document which has nested doc 1 - I do this:
{!parent which='type:maindoc'}
nested_type:nestedType1
But what if I want to search for document which has 2 specific children at the same time?
For example I want to find doc which has both nestedType1 + nestedType2.
Obviously query like this will not work:
{!parent which='type:maindoc'}
nested_type:nestedType1 AND nested_type:nestedType2
So how can I do that? Is that possible at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的事情在我的测试中做到了一个技巧:
({!parent wher ='type:maindoc'v ='nested_type:nestedType1'})和({!parent wher ='type:maindoc'v ='nested_type: NestedType2'})
Something like this did the trick in my testing:
({!parent which='type:maindoc' v='nested_type:nestedType1'}) AND ({!parent which='type:maindoc' v='nested_type:nestedType2'})