elasticsearch nested 对象

创建测试数据

 

 

DELETE student
# 创建 Nested 对象 Mapping
PUT student
{
      "mappings" : {
      "properties" : {
        "name" : {
          "type": "nested",
          "properties" : {
            "first_name" : {"type" : "keyword"},
            "last_name" : {"type" : "keyword"}
          }},
        "commet" : {
          "type" : "text",
          "fields" : {"keyword":{"type":"keyword","ignore_above":256}}
        }
      }
    }
}
POST student/_doc/1
{
  "commet":"good",
  "name":[
    {
      "first_name":"wang ",
      "last_name":"er"
    },

    {
      "first_name":"zhang",
      "last_name":"san"
    }

  ]
}
View Code

 

 Nested 查询 ,hit 为0 ,表示正确

 

 # Nested Aggregation

 

 

 

  

posted on 2021-11-15 12:47  InnoLeo  阅读(28)  评论(0编辑  收藏  举报