从弹性搜索索引中检索嵌入在子文档中的父数据

时间:2020-06-19 10:12:13

标签: elasticsearch search elasticsearch-7

我在弹性搜索中创建了一个名为 testindex 的索引。 索引的映射如下-

{
    "mappings": {
        "properties": {
            "relation_type": {
                "eager_global_ordinals": true,
                "type": "join",
                "relations": {
                    "user": "forum"
                }
            }
        }
    }
}

用户与论坛之间保持父子关系。 我需要在论坛(子)中检索用户(父母)数据。 例如-用户文档

{
  "hn": "handle",
  "iu": "user-image-url",
  "uId": "user-id",
  "relation_type": {
    "name": "user"
  }
}

论坛文档-

{
    "uId": "userId",
    "pId": "postId",
    "relation_type": {
      "name": "forum",
      "parent": "userID"
    }
}

我需要编写一个查询,以使其能够检索子数据内的用户数据(用户图像)。 例如-以下是我想要在论坛(子级)查询结果中使用iu(图像网址)的结果。

{
    "uId": "userId",
    "pId": "postId",
     "iu": "user image" //user image from user doc
    "relation_type": {
      "name": "forum",
      "parent": "userID"
    }
}

0 个答案:

没有答案