对于以下查询,没有任何方面。花了18毫秒。
但是在添加构面之后,它花费了7408毫秒。
我有1.83亿条记录。
构面基于搜索查询提供汇总数据。对???
那么,为什么facet需要这么多时间来对40条记录进行汇总?
无面查询:花费18毫秒
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"country_raw": "united states"
}
},
{
"term": {
"title_raw": "manager"
}
}
]
}
}
}
}
}
无方面查询的响应:
{
"took": 18,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 6,
"failed": 0
},
"hits": {
"total": 40,
"max_score": 1,
"hits": [
....
]
}
}
用小平面查询:花费7845毫秒
{
"size": 0
"facets": {
"title_facet": {
"terms": {
"field": "title_raw",
"size": 5
}
}
},
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"country_raw": "united states"
}
},
{
"term": {
"title_raw": "manager"
}
}
]
}
}
}
}
}
方面查询响应
{
"took": 7408,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 6,
"failed": 0
},
"hits": {
"total": 40,
"max_score": 0,
"hits": [ ]
},
"facets": {
"title_facet": {
"_type": "terms",
"missing": 0,
"total": 40,
"other": 0,
"terms": [
{
"term": "manager",
"count": 40
}
]
}
}
}
最佳答案
您是否尝试过使用“aggs”而不是“facet”(我记得该facet已弃用)ojita
{
"query" : {
"filtered" : {
"filter" : {
"bool" : {
"must" : [{
"term" : {
"country_raw" : "united states"
}
}, {
"term" : {
"title_raw" : "manager"
}
}
]
}
}
}
},
"aggs" : {
"title_facet" : {
"terms" : {
"field" : "title_raw",
"size" : 5
}
}
},
"sort" : {
"_score" : "desc"
}
}
关于elasticsearch - elasticsearch为什么facet这么慢?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37945664/