这是我的映射模板。
{
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 1
},
"mappings" : {
"couchbaseDocument" : {
"properties" : {
"doc" : {
"properties" : {
"exMaterialGroupID" : {
"type" : "string"
},
"materialGroupID" : {
"type" : "string"
},
"materialGroupValue" : {
"type" : "string"
},
"productID" : {
"type" : "string"
},
"productImagePath" : {
"type" : "string",
"fields" : {
"ersoy" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"productName" : {
"type" : "string",
"fields" : {
"ersoy" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"properties" : {
"type" : "nested",
"properties" : {
"id" : {
"type" : "long"
},
"name" : {
"type" : "string",
"fields" : {
"ersoy" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"propertyGroupID" : {
"type" : "long"
}
}
},
"propertyGroups" : {
"properties" : {
"id" : {
"type" : "long"
},
"name" : {
"type" : "string",
"fields" : {
"ersoy" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
},
"propertyOptions" : {
"properties" : {
"id" : {
"type" : "long"
},
"name" : {
"type" : "string",
"fields" : {
"ersoy" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"propertyID" : {
"type" : "long"
}
}
},
"searchKey" : {
"type" : "string",
"fields" : {
"ersoy" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
},
"meta" : {
"properties" : {
"expiration" : {
"type" : "long"
},
"flags" : {
"type" : "long"
},
"id" : {
"type" : "string"
},
"rev" : {
"type" : "string"
}
}
}
}
},
"couchbaseCheckpoint" : {
"properties" : {
"doc" : {
"properties" : {
"uuid" : {
"type" : "string"
}
}
}
}
}
}
}
我的问题是使用此聚合搜索产品
{
"aggs" : {
"product" : {
"nested" : {
"path" : "properties"
},
"aggs" : {
"id" : {
"terms" : {
"field" : "doc.properties.name.ersoy"
}
}
}
}
}
}
我收到此错误。
{
"error": "SearchPhaseExecutionException[Failed to execute phase
[query_fetch], all shards failed; shardFailures {[bFRHdmHASWCZPk-tbyg4Zw] [elastic-products1][0]: AggregationExecutionException[[nested] nested path [properties] not found]}]",
"status": 500
}
我错了,我看不到。任何人都可以帮助我
答案 0 :(得分:1)
请尝试使用此查询,您需要在嵌套路径中使用"doc.properties"
,而不仅仅是"properties"
{
"aggs" : {
"product" : {
"nested" : {
"path" : "doc.properties" <---- fix this line
},
"aggs" : {
"id" : {
"terms" : {
"field" : "doc.properties.name.ersoy"
}
}
}
}
}