首页 > 解决方案 > 来自 ES 的查询对象

问题描述

我有以下 ES 映射

 "students" : {
          "properties" : {
            "tag" : {
              "type" : "nested",
              "properties" : {
                "id" : {
                  "type" : "keyword"
                },
                "name" : {
                  "type" : "text"
                }
              }
            },

我如何从 student->tag->id 查询,因为students未定义为嵌套。

我需要一个可以支持多个 id 匹配的查询

标签: elasticsearch

解决方案


就像这样:

{
  "query": {
    "nested": {
      "path": "students.tag",
      "query": {
        "term": {
          "students.tag.id": "1234"
        }
      }
    }
  }
}

推荐阅读