Class ExtendedLuceneClauseBuilder

java.lang.Object
ca.uhn.fhir.jpa.dao.search.ExtendedLuceneClauseBuilder

public class ExtendedLuceneClauseBuilder extends Object
  • Field Details

    • myPredicateFactory

      public final org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory myPredicateFactory
    • myRootClause

      public final org.hibernate.search.engine.search.predicate.dsl.BooleanPredicateClausesStep<?> myRootClause
    • myModelConfig

      public final ModelConfig myModelConfig
  • Constructor Details

    • ExtendedLuceneClauseBuilder

      public ExtendedLuceneClauseBuilder(ca.uhn.fhir.context.FhirContext myFhirContext, ModelConfig theModelConfig, org.hibernate.search.engine.search.predicate.dsl.BooleanPredicateClausesStep<?> myRootClause, org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory myPredicateFactory)
  • Method Details

    • addResourceTypeClause

      public void addResourceTypeClause(String theResourceType)
      Restrict search to resources of a type
      Parameters:
      theResourceType - the type to match. e.g. "Observation"
    • addTokenUnmodifiedSearch

      public void addTokenUnmodifiedSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theAndOrTerms)
    • getTokenCodeFieldPath

      @Nonnull public static String getTokenCodeFieldPath(String theSearchParamName)
    • getTokenSystemCodeFieldPath

      @Nonnull public static String getTokenSystemCodeFieldPath(@Nonnull String theSearchParamName)
    • addStringTextSearch

      public void addStringTextSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> stringAndOrTerms)
    • addStringExactSearch

      public void addStringExactSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theStringAndOrTerms)
    • addStringContainsSearch

      public void addStringContainsSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theStringAndOrTerms)
    • addStringUnmodifiedSearch

      public void addStringUnmodifiedSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theStringAndOrTerms)
    • addReferenceUnchainedSearch

      public void addReferenceUnchainedSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theReferenceAndOrTerms)
    • addDateUnmodifiedSearch

      public void addDateUnmodifiedSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theDateAndOrTerms)
      Create date clause from date params. The date lower and upper bounds are taken into considertion when generating date query ranges

      Example 1 ('eq' prefix/empty): http://fhirserver/Observation?date=eq2020 would generate the following search clause

       
       {
        "bool": {
          "must": [{
            "range": {
              "sp.date.dt.lower-ord": { "gte": "20200101" }
            }
          }, {
            "range": {
              "sp.date.dt.upper-ord": { "lte": "20201231" }
            }
          }]
        }
       }
       
       

      Example 2 ('gt' prefix): http://fhirserver/Observation?date=gt2020-01-01T08:00:00.000

      No timezone in the query will be taken as localdatetime(for e.g MST/UTC-07:00 in this case) converted to UTC before comparison

       
       {
         "range":{
           "sp.date.dt.upper":{ "gt": "2020-01-01T15:00:00.000000000Z" }
         }
       }
       
       

      Example 3 between dates: http://fhirserver/Observation?date=ge2010-01-01&date=le2020-01

       
       {
         "range":{
           "sp.date.dt.upper-ord":{ "gte":"20100101" }
         },
         "range":{
           "sp.date.dt.lower-ord":{ "lte":"20200101" }
         }
       }
       
       

      Example 4 not equal: http://fhirserver/Observation?date=ne2021

       
       {
          "bool": {
             "should": [{
                "range": {
                   "sp.date.dt.upper-ord": { "lt": "20210101" }
                }
             }, {
                "range": {
                   "sp.date.dt.lower-ord": { "gt": "20211231" }
                }
             }],
             "minimum_should_match": "1"
          }
       }
       
       
      Parameters:
      theSearchParamName - e.g code
      theDateAndOrTerms - The and/or list of DateParam values
    • addQuantityUnmodifiedSearch

      public void addQuantityUnmodifiedSearch(String theSearchParamName, List<List<ca.uhn.fhir.model.api.IQueryParameterType>> theQuantityAndOrTerms)
      Differences with DB search: _ is not all-normalized-or-all-not. Each parameter is applied on quantity or normalized quantity depending on UCUM fitness _ respects ranges for equal and approximate qualifiers Strategy: For each parameter, if it can be canonicalized, it is, and used against 'normalized-value-quantity' index otherwise it is applied as-is to 'value-quantity'