获取映射API让我注意到了这个问题。我不知道究竟是什么问题,但我将解释这个场景
......... Mappping ......... `
PUT /loc_index_nw
{
"mappings": {
"loc_data_nw": {
"properties": {
"primary_name_nw": {"type": "string"},
"location_nw": {"type": "geo_point"},
"id_nw": {"type": "string"},
"locality_nw": {"type" : "string"},
"fav_locations": {
"type": "nested",
"fields": {
"nested_locality_nw": {"type": "geo_point"},
"nested_location_type": {"type": "string"}
}
}
}
}
}
}
`
......... 在索引任何文档之前获取映射(仅获取特定字段的映射) .........
GET loc_index_nw/_mapping/loc_data_nw/field/fav_locations.nested_location_type,fav_locations.nested_locality_nw
......... 样本数据 ......... `
POST /loc_index_nw/loc_data_nw/1
{
"id_nw":1,
"primary_name_nw":"National Sarvodaya School",
"location_nw":{"lat":"19.046304","lon":"72.897536"},
"locality_nw":"chembur",
"fav_locations":[
{
"nested_location_type": "office",
"nested_locality_nw": {"lat":"19.04","lon": "72.89"}
},
{
"nested_location_type": "home",
"nested_locality_nw": {"lat":"19.99","lon": "72.01"}
}
]
}
`
`
POST /loc_index_nw/loc_data_nw/2
{
"id_nw":2,
"primary_name_nw":"Diamond Garden",
"location_nw":{"lat":"19.053493","lon":"72.899992"},
"locality_nw":"chembur",
"fav_locations":[
{
"nested_location_type": "park",
"nested_locality_nw": {"lat":"19.04","lon": "72.89"}
},
{
"nested_location_type": "home",
"nested_locality_nw": {"lat":"19.99","lon": "72.01"}
}
]
}
`
......... 在索引几个文档之前获取映射(仅获取特定字段的映射) .........
GET loc_index_nw/_mapping/loc_data_nw/field/fav_locations.nested_location_type,fav_locations.nested_locality_nw
答案 0 :(得分:1)
您需要在嵌套映射定义中将"fields"
替换为"properties"
。因此,您的映射应如下所示:
PUT /loc_index_nw
{
"mappings": {
"loc_data_nw": {
"properties": {
"primary_name_nw": {"type": "string"},
"location_nw": {"type": "geo_point"},
"id_nw": {"type": "string"},
"locality_nw": {"type" : "string"},
"fav_locations": {
"type": "nested",
"properties": {
"nested_locality_nw": {"type": "geo_point"},
"nested_location_type": {"type": "string"}
}
}
}
}
}
}
当我尝试使用您的文档时,它工作正常。