【发布时间】:2017-10-18 09:53:05
【问题描述】:
我在 Elastic 中看到了一些关于分面搜索的示例,但他们都事先知道您希望创建存储桶的字段。
当我的网上商店有多个类别,每个类别的值属性都不同时,我应该如何工作?
有没有一种方法可以在您运行查询时描述您的文档具有哪些属性(例如按类别过滤)?
我现在有这个问题:
{
"from" : 0, "size" : 10,
"query": {
"bool" : {
"must" : [
{ "terms": {"color": ["red", "green", "purple"]} },
{ "terms": {"make": ["honda", "toyota", "bmw"]} }
]
}
},
"aggregations": {
"all_cars": {
"global": {},
"aggs": {
"colors": {
"filter" : { "terms": {"make": ["honda", "toyota", "bmw"]} },
"aggregations": {
"filtered_colors": { "terms": {"field": "color.keyword"} }
}
},
"makes": {
"filter" : { "terms": {"color": ["red", "green"]} },
"aggregations": {
"filtered_makes": { "terms": {"field": "make.keyword"} }
}
}
}
}
}
}
我如何知道我可以在哪些字段上进行聚合。有没有办法在运行查询后描述文档的属性?所以我可以知道要聚合的可能字段是什么。
【问题讨论】:
标签: elasticsearch elasticsearch-5 elasticsearch-aggregation