Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for track_total_hits #96

Merged
merged 2 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/core/request-body-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ class RequestBodySearch {
return this;
}

/**
* The `track_total_hits` parameter allows you to control how the total number of hits
* should be tracked.
*
* Pass `true`, `false`, or the upper limit (default: `10000`) of hits you want tracked.
*
lostpebble marked this conversation as resolved.
Show resolved Hide resolved
* @param {boolean|number} enableOrLimit
* @returns {RequestBodySearch} returns `this` so that calls can be chained
*/
trackTotalHits(enableOrLimit) {
this._body.track_total_hits = enableOrLimit;
return this;
}

/**
* Allows to control how the `_source` field is returned with every hit.
* You can turn off `_source` retrieval by passing `false`.
Expand Down
9 changes: 9 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ declare namespace esb {
*/
trackScores(enable: boolean): this;

/**
* The track_total_hits parameter allows you to control how the total number of hits should be tracked.
*
* Pass true, false, or the upper limit of hits you want tracked.
*
* @param {boolean|number} enable
*/
trackTotalHits(enable: boolean|number): this;

/**
* Allows to control how the `_source` field is returned with every hit.
* You can turn off `_source` retrieval by passing `false`.
Expand Down
1 change: 1 addition & 0 deletions test/core-test/request-body-search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ test(setsOption, 'sorts', {
keyName: 'sort'
});
test(setsOption, 'trackScores', { param: true });
test(setsOption, 'trackTotalHits', { param: true });
test(setsOption, 'version', { param: true });
test(setsOption, 'explain', { param: true });
test(setsOption, 'highlight', {
Expand Down