Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

fix: allow revinclude to return more than 10 resources #164

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
27 changes: 27 additions & 0 deletions src/__snapshots__/elasticSearchService.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "practitioner-alias",
Expand All @@ -50,6 +51,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "practitionerrole-alias",
Expand All @@ -73,6 +75,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -134,6 +137,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -224,6 +228,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "practitioner-alias",
Expand All @@ -247,6 +252,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -308,6 +314,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -370,6 +377,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -461,6 +469,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -491,6 +500,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -553,6 +563,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "communication-alias",
Expand All @@ -576,6 +587,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "immunizationrecommendation-alias",
Expand All @@ -599,6 +611,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "medicationadministration-alias",
Expand All @@ -622,6 +635,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "provenance-alias",
Expand All @@ -645,6 +659,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "provenance-alias",
Expand All @@ -668,6 +683,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -729,6 +745,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -819,6 +836,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -880,6 +898,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -941,6 +960,7 @@ Array [
],
},
},
"size": 1000,
},
Object {
"index": "provenance-alias",
Expand All @@ -964,6 +984,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -1025,6 +1046,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -1054,6 +1076,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -1396,6 +1419,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -1430,6 +1454,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -1501,6 +1526,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down Expand Up @@ -1535,6 +1561,7 @@ Array [
],
},
},
"size": 1000,
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ export const NON_SEARCHABLE_PARAMETERS = [
export const MAX_ES_WINDOW_SIZE: number = 10000;

export const MAX_CHAINED_PARAMS_RESULT: number = 100;

export const MAX_NUM_ES_HITS: number = 1000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this const is specific to inclusion params. Maybe rename to MAX_INCLUSION_PARAM_RESULTS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the name suggestion, I've updated it as such!

2 changes: 1 addition & 1 deletion src/elasticSearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export class ElasticSearchService implements Search {
const apiResponse = await this.esClient.msearch({
body: searchQueriesWithAlias.flatMap((query) => [
{ index: query.index, ...(request.sessionId && { preference: request.sessionId }) },
{ query: query.body!.query },
{ size: query.size, query: query.body!.query },
]),
});

Expand Down
3 changes: 3 additions & 0 deletions src/searchInclusions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FHIRSearchParametersRegistry } from './FHIRSearchParametersRegistry';
import getComponentLogger from './loggerBuilder';
import { Query } from './elasticSearchService';
import { getAllValuesForFHIRPath } from './getAllValuesForFHIRPath';
import { MAX_NUM_ES_HITS } from './constants';

const logger = getComponentLogger();

Expand Down Expand Up @@ -179,6 +180,7 @@ export const buildIncludeQuery = (
): Query => ({
resourceType,
queryRequest: {
size: MAX_NUM_ES_HITS,
body: {
query: {
bool: {
Expand Down Expand Up @@ -207,6 +209,7 @@ export const buildRevIncludeQuery = (
return {
resourceType: sourceResource,
queryRequest: {
size: MAX_NUM_ES_HITS,
body: {
query: {
bool: {
Expand Down