elasticsearch 运行具有父查询的内部命中查询时,找不到路径的嵌套源

nue99wik  于 2023-01-25  发布在  ElasticSearch
关注(0)|答案(1)|浏览(134)
we are migrating to elastic search 8 and when we are trying to fetch the data of parent document inner hits using has parent query .elastic search returning exception when runnning innerhits for has parent query.

https://discuss.elastic.co/t/inner-hits-in-has-parent-giving-error-couldnt-find-nested-source-for-path-currentcompany/318232

2j4z5cfb

2j4z5cfb1#

我也有同样的问题
下面的查询给我同样的错误:,我必须使用字段而不是**_id**来选择父文档

GET /user_data_factory/_search?from=0&size=20
{
   "query": {
        "bool": {
          "must": [
            {
              "match": {
                "relation_type": "uinsp"
              }
            },
            {
              "bool": {
                "minimum_should_match": 1,
                "should": [
                  {
                    "bool": {
                      "must": [
                        {
                          "match": {
                            "userInspirer": "63bef9f9a8c98000126589eb"
                          }
                        },
                        {
                          "bool": {
                            "minimum_should_match": 1,
                            "should": [
                               {
                                "has_parent": {
                                  "parent_type": "user",
                                  "query": {
                                    "match": {
                                      "_id": "63bd1ff29510390012760322"
                                    }
                                  },
                                   "inner_hits": {
                                    "_source": ["id"]
                                  }
                                }
                              }]
                            
                          }
                        }
                      ]
                    }
                  }]
              
              }
            }
          ]
        }
      }
}

使用字段而不是_id

GET /user_data_factory/_search?from=0&size=20
{
   "query": {
        "bool": {
          "must": [
            {
              "match": {
                "relation_type": "uinsp"
              }
            },
            {
              "bool": {
                "minimum_should_match": 1,
                "should": [
                  {
                    "bool": {
                      "must": [
                        {
                          "match": {
                            "userInspirer": "63bef9f9a8c98000126589eb"
                          }
                        },
                        {
                          "bool": {
                            "minimum_should_match": 1,
                            "should": [
                               {
                                "has_parent": {
                                  "parent_type": "user",
                                  "query": {
                                    "match": {
                                      "id": "63bd1ff29510390012760322"
                                    }
                                  },
                                   "inner_hits": {
                                    "_source": ["id"]
                                  }
                                }
                              }]
                            
                          }
                        }
                      ]
                    }
                  }]
              
              }
            }
          ]
        }
      }
}

相关问题