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)
..
你能幫我嗎?