Jay*_*dal 7 json elasticsearch
我需要有关嵌套json文档的弹性搜索映射的帮助.我在网上搜索了很多,但没有找到任何有用的点信息.假设我有这种类型的数据..
{
  "name" : "Zach",
  "car" : [
    {
      "make" : "Saturn",
      "model" : "SL"
    },
    {
      "make" : "Subaru",
      "model" : "Imprezza"
    }
  ]
}
{
  "name" : "Bob",
  "car" : [
    {
      "make" : "Saturn",
      "model" : "Imprezza"
    }
  ]
}
其中汽车内部可以有任意数量的数据对象.根据弹性搜索文档,我开始知道对于嵌套的json,我必须将类型指定为嵌套.但是没有关于如何在嵌套类型下指定变量的映射信息的信息.
就像上面的例子一样,我可以像这样编写映射.
{
  "person":{
    "properties":{
      "name" : {
        "type" : "string"
      },
      "car":{
        "type" : "nested"
      }
    }
  }
}
但是如何为car.make&car.model?? 提供映射信息
这有效吗,没有任何未来的问题?
{
  "person": {
    "properties": {
      "name" : {
        "type" : "string"
      },
      "car": {
        "type" : "nested"
        "properties": {
          "make": {....},
          "model": {....}
        }
      }
    }
  }
}
And*_*fan 24
你可以这样做:
PUT /my_index
{
  "mappings": {
    "blogpost": {
      "properties": {
        "comments": {
          "type": "nested", 
          "properties": {
            "name":    { "type": "string"  },
            "comment": { "type": "string"  },
            "age":     { "type": "short"   },
            "stars":   { "type": "short"   },
            "date":    { "type": "date"    }
          }
        }
      }
    }
  }
}
引用ES权威指南的这一部分.