solr嵌套文档:对父母文档的查询,该文档具有多个特定的嵌套文档

发布于 2025-02-13 05:27:54 字数 808 浏览 1 评论 0原文

让我们想象我有几个嵌套文档的文档:

{
  "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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掀纱窥君容 2025-02-20 05:27:54

像这样的事情在我的测试中做到了一个技巧:

({!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'})

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文