Код: Выделить всё
GET //_search
{
"query": {
"bool": {
"must": [],
"should": [],
"filter": [
{
"term": {
"deleted": false
}
},
{
"term": {
"companyId.keyword": "my-companyId"
}
},
{
"term": {
"status.keyword": "booked"
}
},
{
"terms": {
"contactId.keyword": [
... All ids (can provide upto 100 ids)
]
}
},
{
"range": {
"startTime": {
"gte":
}
}
}
],
"must_not": []
}
},
"size": ,
"from": 0,
"aggs": {
"groupByContactId": {
"terms": {
"field": "contactId.keyword",
"size":
},
"aggs": {
"nextEvents": {
"top_hits": {
"size": 1,
"sort": [
{
"startTime": {
"order": "asc"
}
}
]
}
}
}
}
},
"sort": [
{
"dateAdded": {
"missing": -9999999999999,
"order": "desc"
}
},
{
"_id": {
"order": "asc"
}
}
],
"track_total_hits": false
}
с < /p>
[*]
Код: Выделить всё
execution_hint
[*] Удаление сортировки на Dateadded и id
Добавление _source.includes ortain в my top_hits
ничего не показало значительного сокращения в законодательстве. Профилирование показывает: < /p>
Код: Выделить всё
GlobalOrdinalsStringTermsAggregator (groupByContactId)
Time Spent: Ranges from ~672K ns to 1.35M ns across shards.
Key Time Consumers:
build_leaf_collector: Dominates with over 600K–1.4M ns.
build_aggregation: Non-trivial (~40K–450K ns).
---------------------
And in one shard Query had a high build_scorer time (~3.6M ns)
Подробнее здесь: https://stackoverflow.com/questions/795 ... -optimized