Ale*_*rov 8 facets elasticsearch
我用3个过滤器过滤了查询:"query": "iphone", color:5, category:10, brand:25.
我怎样才能获得其中有各个品牌的产品数量color:5和category:10?
在Solr我做到了:
fq={!tag=tag_facet_brand}facet_brand:"564"&facet.field={!ex=tag_facet_brand}facet_brand
Run Code Online (Sandbox Code Playgroud)
如何从聚合上下文中排除1个过滤器?(我不能使用全局,因为我松了query:iphone,我不能使用post_filter - 因为性能).
小智 6
我们刚刚离开SOLR,我们面临同样的问题.
您可以尝试全局存储桶,然后为每个存储桶添加查询过滤器:
"filter" : {
"query" : {
"query_string" : {
"query" : "iPhone"
}
}
}
Run Code Online (Sandbox Code Playgroud)
你应该结束这样的事情:
{
"size": 10,
"query": {
"query_string": {
"query": "iphone"
}
},
"filter": {
"bool": {
"must": [
{
"term": {
"brand": "564"
}
},
{
"term": {
"color": "5"
}
},
{
"term": {
"category": "10"
}
}
]
}
},
"aggs": {
"all": {
"global": {},
"aggs": {
"keyword": {
"filter": {
"bool": {
"must": [
{
"query": {
"query_string": {
"query": "iphone"
}
}
},
{
"term": {
"color": "5"
}
},
{
"term": {
"category": "10"
}
}
]
}
},
"aggs": {
"brand": {
"terms": {
"field": "brand"
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2463 次 |
| 最近记录: |