Solr嵌套文档:查询包含多个特定嵌套文档的父文档

wljmcqd8  于 2022-09-27  发布在  Solr
关注(0)|答案(1)|浏览(249)

假设我有一个包含多个嵌套文档的文档:

{
  "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

但是,如果我想同时搜索包含两个特定子级的文档,该怎么办?例如,我想查找同时具有nestedType1+nestedType 2的文档。
显然,这样的查询不起作用:

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

那么我该怎么做呢?那有可能吗?

4uqofj5v

4uqofj5v1#

类似这样的东西在我的测试中发挥了作用:
({!parent which='type:maindoc' v='nested_type:nestedType1'}) AND ({!parent which='type:maindoc' v='nested_type:nestedType2'})

相关问题