mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-09 14:33:32 +00:00
Freetext search tag types support (#3622)
* Handle uri, _tag, _security and _profile freetext search parameters * Fix combined 'and' and 'or' clauses and add tests Use collection instead of typed array to eliminate warnings * Eliminate predicate nesting level * Add changelog * Implement revision suggestions Co-authored-by: juan.marchionatto <juan.marchionatto@smilecdr.com>
This commit is contained in:
parent
6f5eea81b7
commit
464a07e284
@ -0,0 +1,4 @@
|
||||
---
|
||||
type: add
|
||||
issue: 3640
|
||||
title: "Extended Lucene/Elasticsearch indexing of search parameters now supports _tag, _profile and _security."
|
@ -23,9 +23,47 @@ The Extended Lucene string search indexing supports the default search, as well
|
||||
|
||||
The Extended Lucene Indexing supports the default token search by code, system, or system+code,
|
||||
as well as with the `:text` modifier.
|
||||
The `:text` modifier provides the same Simple Query Syntax used by string `:text` searches.
|
||||
The `:text` modifier provides the same Simple Query Syntax used by string `:text` searches.
|
||||
See https://www.hl7.org/fhir/search.html#token.
|
||||
|
||||
|
||||
## Quantity search
|
||||
|
||||
The Extended Lucene Indexing supports the quantity search.
|
||||
See https://www.hl7.org/fhir/search.html#quantity.
|
||||
|
||||
|
||||
## URI search
|
||||
|
||||
The Extended Lucene Indexing supports the URI search.
|
||||
See https://www.hl7.org/fhir/search.html#uri.
|
||||
|
||||
|
||||
## Date search
|
||||
|
||||
We support date searches using the eq, ne, lt, gt, ge, and le comparisons.
|
||||
See https://www.hl7.org/fhir/search.html#date.
|
||||
|
||||
|
||||
## Supported Parameters for all resources
|
||||
| Parameter | Supported | type |
|
||||
| ------------- | ------------- | ------------- |
|
||||
| _id | no | |
|
||||
| _lastUpdated | yes | date |
|
||||
| _tag | yes | token |
|
||||
| _profile | yes | URI |
|
||||
| _security | yes | token |
|
||||
| _text | yes | string |
|
||||
| _content | yes | string |
|
||||
| _list | no |
|
||||
| _has | no |
|
||||
| _type | no |
|
||||
|
||||
## Additional supported Parameters
|
||||
| Parameter | Supported | type |
|
||||
| ------------- | ------------- | ------------- |
|
||||
| _source | yes | URI |
|
||||
|
||||
## ValueSet autocomplete extension
|
||||
|
||||
The Extended Lucene Indexing supports an extension of the `$expand` operation on ValueSet with
|
||||
|
@ -51,7 +51,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -629,15 +628,12 @@ public class ExtendedLuceneClauseBuilder {
|
||||
public void addUriUnmodifiedSearch(String theParamName, List<List<IQueryParameterType>> theUriUnmodifiedAndOrTerms) {
|
||||
for (List<IQueryParameterType> nextAnd : theUriUnmodifiedAndOrTerms) {
|
||||
|
||||
List<PredicateFinalStep> predicates = new ArrayList<>();
|
||||
List<String> orTerms = nextAnd.stream().map(p -> ((UriParam) p).getValue()).collect(Collectors.toList());
|
||||
PredicateFinalStep orTermPredicate = myPredicateFactory.terms()
|
||||
.field(String.join(".", SEARCH_PARAM_ROOT, theParamName, URI_VALUE))
|
||||
.matchingAny(orTerms);
|
||||
|
||||
for (IQueryParameterType paramType : nextAnd) {
|
||||
predicates.add(myPredicateFactory.match()
|
||||
.field(String.join(".", SEARCH_PARAM_ROOT, theParamName, URI_VALUE))
|
||||
.matching( ((UriParam) paramType).getValue() ));
|
||||
}
|
||||
|
||||
myRootClause.must(orPredicateOrSingle(predicates));
|
||||
myRootClause.must(orTermPredicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import ca.uhn.fhir.jpa.model.entity.ResourceLink;
|
||||
import ca.uhn.fhir.jpa.model.search.ExtendedLuceneIndexData;
|
||||
import ca.uhn.fhir.jpa.searchparam.extractor.ISearchParamExtractor;
|
||||
import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.util.ResourceSearchParams;
|
||||
import ca.uhn.fhir.util.MetaUtil;
|
||||
@ -95,10 +94,10 @@ public class ExtendedLuceneIndexExtractor {
|
||||
retVal.addQuantityIndexData(nextParam.getParamName(), nextParam.getUnits(), nextParam.getSystem(), nextParam.getValue().doubleValue()));
|
||||
|
||||
theResource.getMeta().getTag().forEach(tag ->
|
||||
retVal.addTokenIndexData("_tag", new CodingDt(tag.getSystem(), tag.getCode()).setDisplay(tag.getDisplay())));
|
||||
retVal.addTokenIndexData("_tag", tag));
|
||||
|
||||
theResource.getMeta().getSecurity().forEach(sec ->
|
||||
retVal.addTokenIndexData("_security", new CodingDt(sec.getSystem(), sec.getCode()).setDisplay(sec.getDisplay())));
|
||||
retVal.addTokenIndexData("_security", sec));
|
||||
|
||||
theResource.getMeta().getProfile().forEach(prof ->
|
||||
retVal.addUriIndexData("_profile", prof.getValue()));
|
||||
|
@ -91,7 +91,6 @@ import javax.persistence.EntityManager;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -144,11 +144,11 @@ public interface ITestDataBuilder {
|
||||
}
|
||||
|
||||
default Consumer<IBaseResource> withTag(String theSystem, String theCode) {
|
||||
return t -> t.getMeta().addTag().setSystem(theSystem).setCode(theCode).setDisplay(theCode);
|
||||
return t -> t.getMeta().addTag().setSystem(theSystem).setCode(theCode);
|
||||
}
|
||||
|
||||
default Consumer<IBaseResource> withSecurity(String theSystem, String theCode) {
|
||||
return t -> t.getMeta().addSecurity().setSystem(theSystem).setCode(theCode).setDisplay(theCode);
|
||||
return t -> t.getMeta().addSecurity().setSystem(theSystem).setCode(theCode);
|
||||
}
|
||||
|
||||
default Consumer<IBaseResource> withProfile(String theProfile) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user