Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/server/__mocks__/mockDataFromES.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const mockResourcePath = () => {
'*.analyzed': {},
},
},
track_total_hits: true,
};
const fakeResource = {
aggregations: {
Expand Down Expand Up @@ -120,6 +121,7 @@ const mockResourcePath = () => {
'*.analyzed': {},
},
},
track_total_hits: true,
};
const fakeResourceWithFilter1 = {
aggregations: {
Expand Down Expand Up @@ -180,6 +182,7 @@ const mockResourcePath = () => {
'*.analyzed': {},
},
},
track_total_hits: true,
};
const fakeResourceWithFilter2 = {
aggregations: {
Expand Down
8 changes: 7 additions & 1 deletion src/server/__mocks__/mockESData/mockNestedAggs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const mockNestedAggs = () => {
terms: {
field: 'visits.visit_label',
missing_bucket: true,
order: "desc"
order: 'desc',
},
},
},
Expand All @@ -29,6 +29,7 @@ const mockNestedAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeNestedAggs1 = {
aggregations: {
Expand Down Expand Up @@ -67,6 +68,7 @@ const mockNestedAggs = () => {
},
},
},
track_total_hits: true,
};
mockSearchEndpoint(nestedAggsQuery1, fakeNestedAggs1);

Expand All @@ -87,6 +89,7 @@ const mockNestedAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeNestedAggs2 = {
aggregations: {
Expand All @@ -101,6 +104,7 @@ const mockNestedAggs = () => {
},
},
},
track_total_hits: true,
};
mockSearchEndpoint(nestedAggsQuery2, fakeNestedAggs2);

Expand Down Expand Up @@ -134,6 +138,7 @@ const mockNestedAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeNestedAggs3 = {
aggregations: {
Expand Down Expand Up @@ -185,6 +190,7 @@ const mockNestedAggs = () => {
},
},
},
track_total_hits: true,
};
mockSearchEndpoint(nestedAggsQuery3, fakeNestedAggs3);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const mockNestedTermsAndMissingAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeMissingAggs = {
aggregations: {
Expand Down Expand Up @@ -103,6 +104,7 @@ const mockNestedTermsAndMissingAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeTermsAggs = {
aggregations: {
Expand Down Expand Up @@ -167,6 +169,7 @@ const mockNestedTermsAndMissingAggs = () => {
],
},
},
track_total_hits: true,
};
mockSearchEndpoint(termsAggsQuery, fakeTermsAggs);

Expand Down Expand Up @@ -213,6 +216,7 @@ const mockNestedTermsAndMissingAggs = () => {
},
},
},
track_total_hits: true,
};
const combinedTermsAggs = {
aggregations: {
Expand Down Expand Up @@ -286,6 +290,7 @@ const mockNestedTermsAndMissingAggs = () => {
],
},
},
track_total_hits: true,
};
mockSearchEndpoint(combinedAggsQuery, combinedTermsAggs);
};
Expand Down
4 changes: 4 additions & 0 deletions src/server/__mocks__/mockESData/mockNumericAggsGlobalStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const mockNumericAggsGlobalStats = () => {
},
},
},
track_total_hits: true,
};
const fakeFileCountGlobalStatsAggs = {
aggregations: {
Expand Down Expand Up @@ -40,6 +41,7 @@ const mockNumericAggsGlobalStats = () => {
},
},
},
track_total_hits: true,
};
const fakeFileCountGlobalStatsAggs1 = {
aggregations: {
Expand Down Expand Up @@ -84,6 +86,7 @@ const mockNumericAggsGlobalStats = () => {
},
},
},
track_total_hits: true,
};
const fakeFileCountGlobalStatsAggs2 = {
aggregations: {
Expand Down Expand Up @@ -113,6 +116,7 @@ const mockNumericAggsGlobalStats = () => {
},
},
},
track_total_hits: true,
};
const fakeFileCountGlobalStatsAggs3 = {
aggregations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const mockHistogramFixBinCount = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixBinCountResult = {
aggregations: {
Expand Down Expand Up @@ -158,6 +159,7 @@ const mockHistogramFixBinCount = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixBinCountResult1 = {
aggregations: {
Expand Down Expand Up @@ -264,6 +266,7 @@ const mockHistogramFixBinCount = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixBinCountResult2 = {
aggregations: {
Expand Down Expand Up @@ -377,6 +380,7 @@ const mockHistogramFixBinCount = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixBinCountResult3 = {
aggregations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const mockHistogramFixWidth = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixWidthResult = {
aggregations: {
Expand Down Expand Up @@ -107,6 +108,7 @@ const mockHistogramFixWidth = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixWidthResult1 = {
aggregations: {
Expand Down Expand Up @@ -206,6 +208,7 @@ const mockHistogramFixWidth = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixWidthResult2 = {
aggregations: {
Expand Down Expand Up @@ -256,6 +259,7 @@ const mockHistogramFixWidth = () => {
},
},
},
track_total_hits: true,
};
const fileCountHistogramFixWidthResult3 = {
aggregations: {
Expand Down
9 changes: 6 additions & 3 deletions src/server/__mocks__/mockESData/mockTextAggs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mockTextAggs = () => {
terms: {
field: 'gender',
missing_bucket: true,
order: "desc"
order: 'desc',
},
},
},
Expand All @@ -22,6 +22,7 @@ const mockTextAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeGenderAggs = {
aggregations: {
Expand Down Expand Up @@ -80,7 +81,7 @@ const mockTextAggs = () => {
terms: {
field: 'gender',
missing_bucket: true,
order: "desc"
order: 'desc',
},
},
},
Expand All @@ -89,6 +90,7 @@ const mockTextAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeGenderAggs2 = {
aggregations: {
Expand Down Expand Up @@ -141,7 +143,7 @@ const mockTextAggs = () => {
terms: {
field: 'gender',
missing_bucket: true,
order: "desc"
order: 'desc',
},
},
},
Expand All @@ -150,6 +152,7 @@ const mockTextAggs = () => {
},
},
},
track_total_hits: true,
};
const fakeGenderAggs3 = {
aggregations: {
Expand Down
5 changes: 5 additions & 0 deletions src/server/es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ES {
[`*${config.analyzedTextFieldSuffix}`]: {},
},
};
validatedQueryBody.track_total_hits = true;
log.info('[ES.query] index, type, query body: ', esIndex, esType, JSON.stringify(validatedQueryBody));
return this.client.search({
index: esIndex,
Expand Down Expand Up @@ -425,6 +426,10 @@ class ES {
{ esInstance: this, esIndex, esType },
{ filter, fields: false, size: 0 },
);
// Really shouldn't be getting this, but just in case
if (result.hits.total.relation !== 'eq') {
log.error(`The returned total count might be inaccurate. See hits.total object: ${result.hits.total}`);
}
return result.hits.total.value;
}

Expand Down