简体   繁体   中英

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:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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