Allow hsearch sorted offset searches (#3864)
* Start direct HSearch path * Support no HSearch * Spike out the direct resource query * Implement hsearch fast load * Fix last master merge in issues * Implement revision requests * Test direct resources (no IDs query) sorting * Use mock to count freetext searches to avoid implementing interface in test * Remove fixme * Make listener optional as it is used only for tests * Provide new dependency * Widen fast path test scope and fix previously untested configurations * Make method transactional as it can be called from outside a TX (at least testObservationLastNAllParamsPopulated does) * Update test validation * Allow hsearch sorted offset searches * Add changelog Co-authored-by: Michael Buckley <michael.buckley@smilecdr.com> Co-authored-by: juan.marchionatto <juan.marchionatto@smilecdr.com>
This commit is contained in:
parent
b026ac10e5
commit
7010ddd715
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 3863
|
||||||
|
title: "Previously a lucene/elastic enabled sorted search including offset greater than zero was not sorting results.
|
||||||
|
This has now been fixed."
|
||||||
|
|
|
@ -420,7 +420,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc {
|
||||||
.select(this::buildResourceSelectClause)
|
.select(this::buildResourceSelectClause)
|
||||||
.where(f -> buildWhereClause(f, theResourceType, theParams, null));
|
.where(f -> buildWhereClause(f, theResourceType, theParams, null));
|
||||||
|
|
||||||
if (theParams.getSort() != null && offset == 0) {
|
if (theParams.getSort() != null) {
|
||||||
query.sort(
|
query.sort(
|
||||||
f -> myExtendedFulltextSortHelper.getSortClauses(f, theParams.getSort(), theResourceType) );
|
f -> myExtendedFulltextSortHelper.getSortClauses(f, theParams.getSort(), theResourceType) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1504,6 +1504,30 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl
|
||||||
assertNotFind("when one predicate matches each object", "/Observation" +
|
assertNotFind("when one predicate matches each object", "/Observation" +
|
||||||
"?value-quantity=0.06|" + UCUM_CODESYSTEM_URL + "|10*3/L");
|
"?value-quantity=0.06|" + UCUM_CODESYSTEM_URL + "|10*3/L");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@Disabled // These conversions are not supported by the library we use
|
||||||
|
public class TemperatureUnitConversions {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void celsiusToFahrenheit() {
|
||||||
|
withObservationWithQuantity(37.5, UCUM_CODESYSTEM_URL, "Cel" );
|
||||||
|
|
||||||
|
assertFind( "when eq UCUM 99.5 degF", "/Observation?value-quantity=99.5|" + UCUM_CODESYSTEM_URL + "|degF");
|
||||||
|
assertNotFind( "when eq UCUM 101.1 degF", "/Observation?value-quantity=101.1|" + UCUM_CODESYSTEM_URL + "|degF");
|
||||||
|
assertNotFind( "when eq UCUM 97.8 degF", "/Observation?value-quantity=97.8|" + UCUM_CODESYSTEM_URL + "|degF");
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
public void fahrenheitToCelsius() {
|
||||||
|
withObservationWithQuantity(99.5, UCUM_CODESYSTEM_URL, "degF" );
|
||||||
|
|
||||||
|
assertFind( "when eq UCUM 37.5 Cel", "/Observation?value-quantity=99.5|" + UCUM_CODESYSTEM_URL + "|Cel");
|
||||||
|
assertNotFind( "when eq UCUM 38.1 Cel", "/Observation?value-quantity=101.1|" + UCUM_CODESYSTEM_URL + "|Cel");
|
||||||
|
assertNotFind( "when eq UCUM 36.9 Cel", "/Observation?value-quantity=97.8|" + UCUM_CODESYSTEM_URL + "|Cel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2094,6 +2118,20 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl
|
||||||
assertThat(getResultIds(result), contains(raId3, raId2, raId1));
|
assertThat(getResultIds(result), contains(raId3, raId2, raId1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sortWithOffset() {
|
||||||
|
String raId1 = createRiskAssessmentWithPredictionProbability(0.23).getIdPart();
|
||||||
|
String raId2 = createRiskAssessmentWithPredictionProbability(0.38).getIdPart();
|
||||||
|
String raId3 = createRiskAssessmentWithPredictionProbability(0.76).getIdPart();
|
||||||
|
|
||||||
|
myCaptureQueriesListener.clear();
|
||||||
|
IBundleProvider result = myTestDaoSearch.searchForBundleProvider("/RiskAssessment?_sort=-probability&_offset=1");
|
||||||
|
|
||||||
|
assertEquals(0, myCaptureQueriesListener.getSelectQueriesForCurrentThread().size(), "we build the bundle with no sql");
|
||||||
|
// requested profile (uri) descending so order should be id2, id1
|
||||||
|
assertThat(getResultIds(result), contains(raId2, raId1));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|
Loading…
Reference in New Issue