前面写到了object数据类型,这里来说说nested。按照官方文档的说法,nested是特殊的object类型,弥补了object对象不能单独作为整体进行检索的缺陷。为了达到这个目的,nested在es内部是作为隐藏文档存储的。下面来详细说明。
先来看如何创建一个包含nested类型的index:
PUT test_nested
{
"settings": {
"mapping.nested_fields.limit":4,
"mapping.nested_objects.limit":2
},
"mappings": {
"properties": {
"region":{
"type": "keyword"
},
"addr":{
"type": "nested",
"properties": {
"nation":{
"type":"keyword"
},
"citys":{
"type":"nested",
"properties":{
"city":{
"type":"keyword"
}
}
},
"street":{
"type":"text"
},