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

Commit

Permalink
fix: allow revinclude to return more than 10 resources (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssvegaraju authored Feb 1, 2022
1 parent 8c68539 commit b1e3a1a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
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_INCLUSION_PARAM_RESULTS: number = 1000;
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_INCLUSION_PARAM_RESULTS } from './constants';

const logger = getComponentLogger();

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

0 comments on commit b1e3a1a

Please sign in to comment.