1
你能帮助我吗?我有一个拥有超过1000种产品的电子商务网站。每种产品都有一些选项,如“颜色”,“尺寸”和其他规格......但我不知道所有属性。所以我定义文档与此映射:Elastic搜索电子商务商店的列表/内情属性
"mappings" : {
"article" : {
"properties": {
"options": {
"type": "nested",
"include_in_parent":"true",
"properties": {
"id": {"type": "string"},
"name": {"type": "string"},
"values": {"type": "string"}
}
}
}
}
这是我的查询来获取遗愿清单:
{
"query": {
"bool": {
"must": [
{
"term": {
"categorie_id": "f52330ce2669dfab884c2d60468b8466"
}
}
],
"must_not": [],
"should": []
}
},
"from": 0,
"size": 1,
"sort": [
{
"sorttype": {
"order": "desc"
}
},
"_score"
],
"aggs": {
"baked_goods": {
"nested": {
"path": "options"
},
"aggs": {
"name": {
"terms": {
"field": "id"
},
"aggs": {
"name": {
"terms": {
"field": "values"
}
}
}
}
}
}
}
}
我得到的文件,但斗的结果是空的...
"aggregations": {
"baked_goods": {
"doc_count": 3331,
"name": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [ ]
}
}
}
我想是这样的:
"color" => "red" (4)
"color" => "blue" (2)
"size" => "X" (11)
..
你能帮我吗?