Add JPA_PERFTRACE_INFO invocation to Fulltext Searches (#5072)

* Changelog

* basic test

* Api change for fulltext, add test

* Add javadocs

* Refactor to use a simpler method

* Review comments
This commit is contained in:
Tadgh 2023-07-11 13:32:02 -07:00 committed by GitHub
parent eb06b473b9
commit 1ce2043dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 154 additions and 57 deletions

View File

@ -0,0 +1,5 @@
---
type: add
issue: 5071
title: "Previously, calls to the Fulltext Search service (Lucene/Elasticsearch) did not invoker the `JPA_PERFTRACE_INFO`. Now, they invoke this pointcut with information
of which query went out to the fulltext system."

View File

@ -21,6 +21,9 @@ package ca.uhn.fhir.jpa.dao;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
import ca.uhn.fhir.jpa.dao.search.ExtendedHSearchClauseBuilder;
@ -32,6 +35,7 @@ import ca.uhn.fhir.jpa.dao.search.LastNOperation;
import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.jpa.model.search.ExtendedHSearchIndexData;
import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage;
import ca.uhn.fhir.jpa.search.autocomplete.ValueSetAutocompleteOptions;
import ca.uhn.fhir.jpa.search.autocomplete.ValueSetAutocompleteSearch;
import ca.uhn.fhir.jpa.search.builder.ISearchQueryExecutor;
@ -42,7 +46,10 @@ import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
import ca.uhn.fhir.rest.server.util.ResourceSearchParams;
import com.google.common.collect.Ordering;
@ -101,6 +108,8 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
private IHSearchSortHelper myExtendedFulltextSortHelper;
@Autowired(required = false)
private IHSearchEventListener myHSearchEventListener;
@Autowired
private IInterceptorBroadcaster myInterceptorBroadcaster;
private Boolean ourDisabled;
@ -140,29 +149,31 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
}
@Override
public ISearchQueryExecutor searchNotScrolled(String theResourceName, SearchParameterMap theParams, Integer theMaxResultsToFetch) {
public ISearchQueryExecutor searchNotScrolled(String theResourceName, SearchParameterMap theParams, Integer theMaxResultsToFetch, RequestDetails theRequestDetails) {
validateHibernateSearchIsEnabled();
return doSearch(theResourceName, theParams, null, theMaxResultsToFetch);
return doSearch(theResourceName, theParams, null, theMaxResultsToFetch, theRequestDetails);
}
// keep this in sync with supportsSomeOf();
private ISearchQueryExecutor doSearch(String theResourceType, SearchParameterMap theParams,
IResourcePersistentId theReferencingPid, Integer theMaxResultsToFetch) {
IResourcePersistentId theReferencingPid, Integer theMaxResultsToFetch, RequestDetails theRequestDetails) {
int offset = theParams.getOffset() == null ? 0 : theParams.getOffset();
int count = getMaxFetchSize(theParams, theMaxResultsToFetch);
// perform an offset search instead of a scroll one, which doesn't allow for offset
List<Long> queryFetchResult = getSearchQueryOptionsStep(theResourceType, theParams, theReferencingPid).fetchHits(offset, count);
SearchQueryOptionsStep<?, Long, SearchLoadingOptionsStep, ?, ?> searchQueryOptionsStep = getSearchQueryOptionsStep(theResourceType, theParams, theReferencingPid);
logQuery(searchQueryOptionsStep, theRequestDetails);
List<Long> longs = searchQueryOptionsStep.fetchHits(offset, count);
// indicate param was already processed, otherwise queries DB to process it
theParams.setOffset(null);
return SearchQueryExecutors.from(queryFetchResult);
return SearchQueryExecutors.from(longs);
}
private int getMaxFetchSize(SearchParameterMap theParams, Integer theMax) {
if (theMax != null) {
return theMax;
@ -261,11 +272,11 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
}
@Override
public List<IResourcePersistentId> everything(String theResourceName, SearchParameterMap theParams, IResourcePersistentId theReferencingPid) {
public List<IResourcePersistentId> everything(String theResourceName, SearchParameterMap theParams, IResourcePersistentId theReferencingPid, RequestDetails theRequestDetails) {
validateHibernateSearchIsEnabled();
// todo mb what about max results here?
List<IResourcePersistentId> retVal = toList(doSearch(null, theParams, theReferencingPid, 10_000), 10_000);
List<IResourcePersistentId> retVal = toList(doSearch(null, theParams, theReferencingPid, 10_000,theRequestDetails), 10_000);
if (theReferencingPid != null) {
retVal.add(theReferencingPid);
}
@ -303,9 +314,9 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
@Transactional()
@Override
public List<IResourcePersistentId> search(String theResourceName, SearchParameterMap theParams) {
public List<IResourcePersistentId> search(String theResourceName, SearchParameterMap theParams, RequestDetails theRequestDetails) {
validateHibernateSearchIsEnabled();
return toList(doSearch(theResourceName, theParams, null, DEFAULT_MAX_NON_PAGED_SIZE), DEFAULT_MAX_NON_PAGED_SIZE);
return toList(doSearch(theResourceName, theParams, null, DEFAULT_MAX_NON_PAGED_SIZE, theRequestDetails ), DEFAULT_MAX_NON_PAGED_SIZE);
}
/**
@ -412,7 +423,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
@Override
@Transactional(readOnly = true)
public List<IBaseResource> searchForResources(String theResourceType, SearchParameterMap theParams) {
public List<IBaseResource> searchForResources(String theResourceType, SearchParameterMap theParams, RequestDetails theRequestDetails) {
int offset = 0;
int limit = theParams.getCount() == null ? DEFAULT_MAX_PAGE_SIZE : theParams.getCount();
@ -433,11 +444,31 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
f -> myExtendedFulltextSortHelper.getSortClauses(f, theParams.getSort(), theResourceType));
}
logQuery(query, theRequestDetails);
List<ExtendedHSearchResourceProjection> extendedLuceneResourceProjections = query.fetchHits(offset, limit);
return resourceProjectionsToResources(extendedLuceneResourceProjections);
}
/**
* Fire the JPA_PERFTRACE_INFO hook if it is enabled
* @param theQuery the query to log
* @param theRequestDetails the request details
*/
@SuppressWarnings("rawtypes")
private void logQuery(SearchQueryOptionsStep theQuery, RequestDetails theRequestDetails) {
if (CompositeInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_INFO, myInterceptorBroadcaster, theRequestDetails)) {
StorageProcessingMessage storageProcessingMessage = new StorageProcessingMessage();
String queryString = theQuery.toQuery().queryString();
storageProcessingMessage.setMessage(queryString);
HookParams params = new HookParams()
.add(RequestDetails.class, theRequestDetails)
.addIfMatchesType(ServletRequestDetails.class, theRequestDetails)
.add(StorageProcessingMessage.class, storageProcessingMessage);
CompositeInterceptorBroadcaster.doCallHooks(myInterceptorBroadcaster, theRequestDetails, Pointcut.JPA_PERFTRACE_INFO, params);
}
}
@Override
public boolean supportsAllOf(SearchParameterMap theParams) {

View File

@ -25,6 +25,7 @@ import ca.uhn.fhir.jpa.search.autocomplete.ValueSetAutocompleteOptions;
import ca.uhn.fhir.jpa.search.builder.ISearchQueryExecutor;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
import org.hl7.fhir.instance.model.api.IBaseResource;
@ -38,22 +39,24 @@ public interface IFulltextSearchSvc {
* Search the Lucene/Elastic index for pids using params supported in theParams,
* consuming entries from theParams when used to query.
*
* @param theResourceName the resource name to restrict the query.
* @param theParams the full query - modified to return only params unused by the index.
* @param theResourceName the resource name to restrict the query.
* @param theParams the full query - modified to return only params unused by the index.
* @param theRequestDetails The request details
* @return the pid list for the matchign resources.
*/
<T extends IResourcePersistentId> List<T> search(String theResourceName, SearchParameterMap theParams);
<T extends IResourcePersistentId> List<T> search(String theResourceName, SearchParameterMap theParams, RequestDetails theRequestDetails);
/**
* Query the index for a plain list (non-scrollable) iterator of results.
*
* @param theResourceName e.g. Patient
* @param theParams The search query
* @param theResourceName e.g. Patient
* @param theParams The search query
* @param theMaxResultsToFetch maximum results to fetch
* @param theRequestDetails The request details
* @return Iterator of result PIDs
*/
ISearchQueryExecutor searchNotScrolled(String theResourceName, SearchParameterMap theParams, Integer theMaxResultsToFetch);
ISearchQueryExecutor searchNotScrolled(String theResourceName, SearchParameterMap theParams, Integer theMaxResultsToFetch, RequestDetails theRequestDetails);
/**
* Autocomplete search for NIH $expand contextDirection=existing
@ -62,7 +65,7 @@ public interface IFulltextSearchSvc {
*/
IBaseResource tokenAutocompleteValueSetSearch(ValueSetAutocompleteOptions theOptions);
<T extends IResourcePersistentId> List<T> everything(String theResourceName, SearchParameterMap theParams, T theReferencingPid);
<T extends IResourcePersistentId> List<T> everything(String theResourceName, SearchParameterMap theParams, T theReferencingPid, RequestDetails theRequestDetails);
boolean isDisabled();
@ -95,7 +98,7 @@ public interface IFulltextSearchSvc {
*/
long count(String theResourceName, SearchParameterMap theParams);
List<IBaseResource> searchForResources(String theResourceType, SearchParameterMap theParams);
List<IBaseResource> searchForResources(String theResourceType, SearchParameterMap theParams, RequestDetails theRequestDetails);
boolean supportsAllOf(SearchParameterMap theParams);

View File

@ -72,7 +72,7 @@ public class SearchStrategyFactory {
return new SimpleBundleProvider(Collections.emptyList(), theSearchUUID);
}
List<IBaseResource> resources = myFulltextSearchSvc.searchForResources(theResourceType, theParams);
List<IBaseResource> resources = myFulltextSearchSvc.searchForResources(theResourceType, theParams, theRequestDetails);
SimpleBundleProvider result = new SimpleBundleProvider(resources, theSearchUUID);
result.setSize(resources.size());
return result;

View File

@ -357,10 +357,10 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
fulltextMatchIds = executeLastNAgainstIndex(theMaximumResults);
resultCount = fulltextMatchIds.size();
} else if (myParams.getEverythingMode() != null) {
fulltextMatchIds = queryHibernateSearchForEverythingPids();
fulltextMatchIds = queryHibernateSearchForEverythingPids(theRequest);
resultCount = fulltextMatchIds.size();
} else {
fulltextExecutor = myFulltextSearchSvc.searchNotScrolled(myResourceName, myParams, myMaxResultsToFetch);
fulltextExecutor = myFulltextSearchSvc.searchNotScrolled(myResourceName, myParams, myMaxResultsToFetch, theRequest);
}
if (fulltextExecutor == null) {
@ -460,7 +460,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
}
}
private List<JpaPid> queryHibernateSearchForEverythingPids() {
private List<JpaPid> queryHibernateSearchForEverythingPids(RequestDetails theRequestDetails) {
JpaPid pid = null;
if (myParams.get(IAnyResource.SP_RES_ID) != null) {
String idParamValue;
@ -475,7 +475,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
pid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId, myResourceName, idParamValue);
}
List<JpaPid> pids = myFulltextSearchSvc.everything(myResourceName, myParams, pid);
List<JpaPid> pids = myFulltextSearchSvc.everything(myResourceName, myParams, pid, theRequestDetails);
return pids;
}

View File

@ -2,6 +2,8 @@ package ca.uhn.fhir.jpa.dao.r4;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.ValueSetExpansionOptions;
import ca.uhn.fhir.interceptor.api.Hook;
import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
@ -20,6 +22,7 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink;
import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage;
import ca.uhn.fhir.jpa.search.CompositeSearchParameterTestCases;
import ca.uhn.fhir.jpa.search.QuantitySearchParameterTestCases;
import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc;
@ -85,6 +88,7 @@ import org.junit.jupiter.params.provider.EnumSource;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.aop.support.Pointcuts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.annotation.DirtiesContext;
@ -117,8 +121,13 @@ import static ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.equalToCompressingWhiteSpace;
import static org.hamcrest.Matchers.equalToIgnoringWhiteSpace;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
@ -255,8 +264,55 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl
myStorageSettings.setStoreResourceInHSearchIndex(defaultConfig.isStoreResourceInHSearchIndex());
}
class ElasticPerformanceTracingInterceptor {
private List<StorageProcessingMessage> messages = new ArrayList<>();
@Hook(Pointcut.JPA_PERFTRACE_INFO)
public void logPerformance(StorageProcessingMessage theMessage) {
messages.add(theMessage);
}
public List<StorageProcessingMessage> getMessages() {
return messages;
}
}
@Test
public void testFullTextSearchesArePerformanceLogged() {
ElasticPerformanceTracingInterceptor elasticPerformanceTracingInterceptor = new ElasticPerformanceTracingInterceptor();
myInterceptorRegistry.registerInterceptor(elasticPerformanceTracingInterceptor);
Observation obs1 = new Observation();
obs1.getCode().setText("Systolic Blood Pressure");
obs1.setStatus(Observation.ObservationStatus.FINAL);
obs1.setValue(new Quantity(123));
obs1.getNoteFirstRep().setText("obs1");
IIdType id1 = myObservationDao.create(obs1, mySrd).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs2.getCode().setText("Diastolic Blood Pressure");
obs2.setStatus(Observation.ObservationStatus.FINAL);
obs2.setValue(new Quantity(81));
IIdType id2 = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap map;
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("blood"));
assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(map)), containsInAnyOrder(toValues(id1, id2)));
//Then: The Elasticsearch Query should be logged.
assertThat(elasticPerformanceTracingInterceptor.getMessages(), hasSize(3));
StorageProcessingMessage storageProcessingMessage = elasticPerformanceTracingInterceptor.getMessages().get(2);
assertThat(storageProcessingMessage.getMessage(), containsString("\"query\":\"( blood* )\""));
myInterceptorRegistry.unregisterInterceptor(elasticPerformanceTracingInterceptor);
}
@Test
public void testResourceTextSearch() {
Observation obs1 = new Observation();
obs1.getCode().setText("Systolic Blood Pressure");
obs1.setStatus(Observation.ObservationStatus.FINAL);

View File

@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.model.dstu2.resource.Organization;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
@ -59,7 +60,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// OR
@ -68,7 +69,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// AND
@ -78,7 +79,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// AND OR
@ -88,7 +89,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// All Resource Types
@ -97,7 +98,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")).addOr(new StringParam("DDD")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(null, map);
List<JpaPid> found = mySearchDao.search(null, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3));
}
@ -127,7 +128,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// OR
@ -136,7 +137,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// AND
@ -146,7 +147,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// AND OR
@ -156,7 +157,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// Tag Contents
@ -165,7 +166,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("div")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), empty());
}
}

View File

@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.model.dao.JpaPid;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
@ -60,7 +61,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// OR
@ -69,7 +70,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// AND
@ -79,7 +80,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// AND OR
@ -89,7 +90,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// All Resource Types
@ -98,7 +99,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")).addOr(new StringParam("DDD")));
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(null, map);
List<JpaPid> found = mySearchDao.search(null, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3));
}
@ -133,7 +134,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// OR
@ -142,7 +143,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// AND
@ -152,7 +153,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// AND OR
@ -162,7 +163,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// Tag Contents
@ -171,7 +172,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
content.addAnd(new StringOrListParam().addOr(new StringParam("div")));
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), empty());
}
}

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
@ -63,7 +64,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
params.add("_content", new StringParam(content));
// test
List<JpaPid> ids = mySearchDao.search("Patient", params);
List<JpaPid> ids = mySearchDao.search("Patient", params, SystemRequestDetails.newSystemRequestAllPartitions());
// verify results
Assertions.assertEquals(1, ids.size());
@ -133,7 +134,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// OR
@ -144,7 +145,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, content);
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// AND
@ -155,7 +156,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// AND OR
@ -166,7 +167,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// All Resource Types
@ -176,7 +177,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, content);
List<JpaPid> found = mySearchDao.search(null, map);
List<JpaPid> found = mySearchDao.search(null, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3));
}
@ -212,7 +213,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// OR
@ -222,7 +223,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// AND
@ -233,7 +234,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
}
// AND OR
@ -244,7 +245,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
}
// Tag Contents
@ -254,7 +255,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
map = new SearchParameterMap();
map.add(Constants.PARAM_TEXT, content);
List<JpaPid> found = mySearchDao.search(resourceName, map);
List<JpaPid> found = mySearchDao.search(resourceName, map, SystemRequestDetails.newSystemRequestAllPartitions());
assertThat(JpaPid.toLongList(found), empty());
}
}

View File

@ -372,7 +372,7 @@ public abstract class BaseJpaR4BTest extends BaseJpaTest implements ITestDataBui
protected ITermDeferredStorageSvc myTermDeferredStorageSvc;
@Autowired
private IValidationSupport myJpaValidationSupportChain;
private PerformanceTracingLoggingInterceptor myPerformanceTracingLoggingInterceptor;
protected PerformanceTracingLoggingInterceptor myPerformanceTracingLoggingInterceptor;
private List<Object> mySystemInterceptors;
@Autowired
private DaoRegistry myDaoRegistry;

View File

@ -76,7 +76,6 @@ public class ReadR4Test {
}
}
@Test
public void testReadUsingPlainProvider() throws Exception {
myRestfulServerExtension.getRestfulServer().registerProvider(new PlainGenericPatientProvider());