query
+ aggregation
与query
appart中的aggregation
之间的响应略有不同,是否有任何性能差异? (总命中和额外层)。
我在网址中使用?query_type=count
来跳过文档检索阶段。
查询+聚合
{
"query": {
"match": {
"_all": {
"query": "Plastic"
}
}
},
"aggs": {
"count_by_type": {
"terms": {
"field": "_type"
}
}
}
}
# Response
{
"hits": {"total": 15},
"aggregations": {
"count_by_type": {
"buckets":[
{"key":"product","doc_count":15}
]
}}}
在聚合内部查询
{
"aggs": {
"shop_stuff": {
"filter": {
"query": {
"match": {
"_all": {
"query": "Plastic"
}
}
}
},
"aggs": {
"count_by_type": {
"terms": {
"field": "_type"
}
}
}
}
}
}
# Response
{
"hits": {"total":165},
"aggregations": {
"agg_stuff": {
"doc_count":15,
"count_by_type": {
"buckets":[
{"key":"product","doc_count":15}
]
}}}}