简体   繁体   English

Solr 嵌套文档:查询具有多个特定嵌套文档的父文档

[英]Solr Nested Documents: query for parent document which has several specific nested documents

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:所以现在如果我想搜索嵌套了 doc 1 的文档 - 我这样做:

{!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?但是,如果我想搜索同时有 2 个特定孩子的文档怎么办? For example I want to find doc which has both nestedType1 + nestedType2.例如,我想找到同时具有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?这有可能吗?

这样的事情在我的测试中起到了作用:

({!parent which='type:maindoc' v='nested_type:nestedType1'}) AND ({!parent which='type:maindoc' v='nested_type:nestedType2'})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM