Skip to content

Commit 4354aae

Browse files
committed
feat(config): Allow sending track_total_hits with ES query
A few versions ago, Elasticsearch introduced an optimization where they only approximate the total hit count for a query (max of 10,000). It's of course nice to get better performance, but having hit count information is also super useful to examine queries for our own optimization. This change allows us to enable the [`track_total_hits`](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search#operation-search-track_total_hits) flag on ES queries, with the similar `api.track_total_hits` boolean in `pelias.json`.
1 parent 88146c0 commit 4354aae

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

controller/search.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ function setup( peliasConfig, esclient, query, should_execute ){
5959
cmd.explain = true;
6060
}
6161

62+
if (_.get(apiConfig, 'trackTotalHits') === true) {
63+
cmd.track_total_hits = true;
64+
}
65+
6266
// support for the 'clean.exposeInternalDebugTools' config flag
6367
let debugUrl;
6468
if (_.get(req, 'clean.exposeInternalDebugTools') === true) {

0 commit comments

Comments
 (0)