ELK,萌萌哒

es中join类型使用has_child,基于子文档查询父文档,其中父文档的某些字段还需要做一些过滤如何实现

Elasticsearch | 作者 Jsen | 发布于2020年07月31日 | 阅读数:2208

比如下面的这个嵌套查询逻辑如何实现:"query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "relatedcompyarray",
            "query": {
              "bool": {
                "must": [
                  {
                    "bool": {
                      "should": [
                        {
                          "bool": {
                            "must": [
                              {
                                "terms": {
                                  "relatedcompyarray.company_id": [
                                    "VALUE1",
                                    "VALUE2"
                                  ]
                                }
                              },
                              {
                                "terms": {
                                  "relatedcompyarray.person_nm": [
                                    "VALUE1",
                                    "VALUE2"
                                  ]
                                }
                              },
                              {
                                "range": {
                                  "relatedcompyarray.relevance": {
                                    "gte": 10,
                                    "lte": 20
                                  }
                                }
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "term": {
            "data_type": {
              "value": "VALUE"
            }
          }
        },
        {
          "range": {
            "notice_dt": {
              "gte": "now-180d/d",
              "lte": "now+3d/d"
            }
          }
        },
        {
          "term": {
            "is_del": {
              "value": "0"
            }
          }
        }
      ]
    }
  }
}
已邀请:

要回复问题请先登录注册