Elasticsearch之Nested Object Mapping,elasticsearch


                                         (这是一个小系列:请戳:ElasticsearchNested(嵌套)系列,查看其他nested相关文章)

Setting up a nested field is simple—where you would normally specify type object, make it type nested instead:

  创建一个nested 字段很简单——只要在你通常指定object类型的地方,改成nested类型就行:

 

curl -XPUT 'localhost:9200/my_index' -d '
{
  "mappings":{
     "blogpost":{
	     "properties":{
		     "comments":{
			    "type":"nested",
				"properties":{
				   "name":    {"type":"string"    },
				   "comment": { "type": "string"  },
                   "age":     { "type": "short"   },
                   "stars":   { "type": "short"   },
                   "date":    { "type": "date"    }
				}
			 }
		 }
	 }
  }
}

原文:http://www.elastic.co/guide/en/elasticsearch/guide/master/nested-mapping.html

相关内容