Skip to content

Commit

Permalink
Merge pull request #148 from social-native/feat/track-total-hits
Browse files Browse the repository at this point in the history
Add track_total_hits
  • Loading branch information
markrsocialnative authored May 28, 2021
2 parents 5ea0ff5 + 95370f4 commit a21862c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion __tests__/integration/filters/set_filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ describe('Filters', () => {
query: {bool: {should: [{term: {boolean_field: true}}]}},
size: 10,
sort: ['_score', '_doc'],
track_scores: true
track_scores: true,
track_total_hits: true
});
});

Expand Down
9 changes: 6 additions & 3 deletions __tests__/integration/manager/set_user_state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe('Manager', () => {
query: {bool: {should: [{exists: {field: fakeField}}]}},
size: 10,
sort: ['_score', '_doc'],
track_scores: true
track_scores: true,
track_total_hits: true,
});
});
});
Expand Down Expand Up @@ -65,7 +66,8 @@ describe('Manager', () => {
query: {bool: {should: [{exists: {field: fakeBooleanField}}]}},
size: 10,
sort: ['_score', '_doc'],
track_scores: true
track_scores: true,
track_total_hits: true,
});
});

Expand All @@ -79,7 +81,8 @@ describe('Manager', () => {
query: {bool: {must: [{range: {[fakeRangeField]: {gt: 0, lt: 100}}}]}},
size: 10,
sort: ['_score', '_doc'],
track_scores: true
track_scores: true,
track_total_hits: true
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elastic-composer",
"version": "4.7.0",
"version": "4.7.1",
"description": "",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
Expand Down
2 changes: 1 addition & 1 deletion src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ class Manager<
// pageSize param can be used to override the default page size
pageSize: number | undefined = undefined
): ESRequest => {
return {...request, size: pageSize || this.pageSize, track_scores: true};
return {...request, size: pageSize || this.pageSize, track_scores: true, track_total_hits: true};
};

public _addSortToQuery = (request: ESRequest): ESRequest => {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type ESRequest = {
from?: number;
size?: number;
track_scores?: boolean;
track_total_hits?: boolean;
sort?: ESRequestSortField;
search_after?: ESRequestSortField;
};
Expand Down

0 comments on commit a21862c

Please sign in to comment.