diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 414ffd43749..193a2aa924c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -3468,7 +3468,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { } @Test - public void testNearSearch() { + public void testNearSearchExact() { Location loc = new Location(); double latitude = 1000.0; double longitude = 2000.0; @@ -3478,7 +3478,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { SearchParameterMap map = new SearchParameterMap(); map.add(Location.SP_NEAR, new TokenParam(latitude + ":" + longitude)); - map.add(Location.SP_NEAR_DISTANCE, new QuantityParam(10L)); + map.add(Location.SP_NEAR_DISTANCE, new QuantityParam(0L)); List ids = toUnqualifiedVersionlessIdValues(myLocationDao.search(map)); assertThat(ids, contains(locId)); diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java index 4cba9c12d69..5325696e2ad 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java @@ -275,8 +275,9 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor case "Consent.source": // Consent#source-identifier has a path that isn't typed - This is a one-off to deal with that return; + // FIXME KHS case "Location.position": - ourLog.warn("Position search not currently supported, not indexing location"); + addCoords_Position(resourceTypeName, params, searchParam, value); return; case "StructureDefinition.context": // TODO: implement this @@ -336,19 +337,19 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor return extractSearchParams(theResource, extractor, RestSearchParameterTypeEnum.URI); } - @Override - public SearchParamSet extractSearchParamCoords(IBaseResource theResource) { - IExtractor extractor = (params, searchParam, value, path) -> { - if (value.getClass().equals(myLocationPositionDefinition.getImplementingClass())) { - String resourceType = toRootTypeName(theResource); - addCoords_Position(resourceType, params, searchParam, value); - } else { - addUnexpectedDatatypeWarning(params, searchParam, value); - } - }; - - return extractSearchParams(theResource, extractor, RestSearchParameterTypeEnum.TOKEN); - } +// @Override +// public SearchParamSet extractSearchParamCoords(IBaseResource theResource) { +// IExtractor extractor = (params, searchParam, value, path) -> { +// if (value.getClass().equals(myLocationPositionDefinition.getImplementingClass())) { +// String resourceType = toRootTypeName(theResource); +// addCoords_Position(resourceType, params, searchParam, value); +// } else { +// addUnexpectedDatatypeWarning(params, searchParam, value); +// } +// }; +// +// return extractSearchParams(theResource, extractor, RestSearchParameterTypeEnum.TOKEN); +// } @Override public SearchParamSet extractSearchParamDates(IBaseResource theResource) { @@ -723,7 +724,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor } // FIXME KHS split this class up - private void addCoords_Position(String theResourceType, SearchParamSet theParams, RuntimeSearchParam theSearchParam, IBase theValue) { + private void addCoords_Position(String theResourceType, SearchParamSet theParams, RuntimeSearchParam theSearchParam, IBase theValue) { BigDecimal latitude = null; BigDecimal longitude = null; if (theValue instanceof Location.LocationPositionComponent) { diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java index 0f9304e36a4..55780e54aa0 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/ISearchParamExtractor.java @@ -28,7 +28,7 @@ import java.util.*; public interface ISearchParamExtractor { - SearchParamSet extractSearchParamCoords(IBaseResource theResource); +// SearchParamSet extractSearchParamCoords(IBaseResource theResource); SearchParamSet extractSearchParamDates(IBaseResource theResource); diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java index d49d828e240..f48a632f34e 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java @@ -67,15 +67,17 @@ public class SearchParamExtractorService { handleWarnings(theRequestDetails, myInterceptorBroadcaster, uris); theParams.myUriParams.addAll(uris); - ISearchParamExtractor.SearchParamSet coords = extractSearchParamCoords(theResource); - handleWarnings(theRequestDetails, myInterceptorBroadcaster, coords); - theParams.myCoordsParams.addAll(coords); +// ISearchParamExtractor.SearchParamSet coords = extractSearchParamCoords(theResource); +// handleWarnings(theRequestDetails, myInterceptorBroadcaster, coords); +// theParams.myCoordsParams.addAll(coords); ourLog.trace("Storing date indexes: {}", theParams.myDateParams); for (BaseResourceIndexedSearchParam next : extractSearchParamTokens(theResource)) { if (next instanceof ResourceIndexedSearchParamToken) { theParams.myTokenParams.add((ResourceIndexedSearchParamToken) next); + } else if (next instanceof ResourceIndexedSearchParamCoords) { + theParams.myCoordsParams.add((ResourceIndexedSearchParamCoords) next); } else { theParams.myStringParams.add((ResourceIndexedSearchParamString) next); } @@ -113,9 +115,9 @@ public class SearchParamExtractorService { } } - private ISearchParamExtractor.SearchParamSet extractSearchParamCoords(IBaseResource theResource) { - return mySearchParamExtractor.extractSearchParamCoords(theResource); - } +// private ISearchParamExtractor.SearchParamSet extractSearchParamCoords(IBaseResource theResource) { +// return mySearchParamExtractor.extractSearchParamCoords(theResource); +// } private ISearchParamExtractor.SearchParamSet extractSearchParamDates(IBaseResource theResource) { return mySearchParamExtractor.extractSearchParamDates(theResource); diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java index 38d2b06cb6b..c74955360e9 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3Test.java @@ -197,9 +197,9 @@ public class SearchParamExtractorDstu3Test { SearchParamExtractorDstu3 extractor = new SearchParamExtractorDstu3(new ModelConfig(), ourCtx, ourValidationSupport, searchParamRegistry); extractor.start(); - Set coords = extractor.extractSearchParamCoords(loc); + ISearchParamExtractor.SearchParamSet coords = extractor.extractSearchParamTokens(loc); assertEquals(1, coords.size()); - ResourceIndexedSearchParamCoords coord = coords.iterator().next(); + ResourceIndexedSearchParamCoords coord = (ResourceIndexedSearchParamCoords) coords.iterator().next(); assertEquals(latitude, coord.getLatitude(), 0.0); assertEquals(longitude, coord.getLongitude(), 0.0); } diff --git a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorMegaTest.java b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorMegaTest.java index 3fc6475bcd0..7617c41208b 100644 --- a/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorMegaTest.java +++ b/hapi-fhir-jpaserver-searchparam/src/test/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorMegaTest.java @@ -178,9 +178,10 @@ public class SearchParamExtractorMegaTest { ISearchParamExtractor.SearchParamSet set; - set = theExtractor.extractSearchParamCoords(resource); - assertEquals(0, set.getWarnings().size()); - theIndexesCounter.addAndGet(set.size()); + // FIXME KHS +// set = theExtractor.extractSearchParamCoords(resource); +// assertEquals(0, set.getWarnings().size()); +// theIndexesCounter.addAndGet(set.size()); set = theExtractor.extractSearchParamDates(resource); assertEquals(0, set.getWarnings().size());