我在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"} }
}
}
}
}
}
}
我怎么知道我可以在哪些领域进行聚合 . 有没有办法在运行查询后描述文档的属性?所以我可以知道聚合的可能字段是什么 .
2 回答
现在我将我文章的所有属性存储在一个数组中,我可以像这样快速聚合它们:
这是向正确方向迈出的一步,但这样我不知道属性的类型是什么 .
这是一个示例对象
您可以使用过滤器聚合来过滤,然后在里面创建一个术语聚合?