5.5.1Combo Search Index Parameters

 

HAPI FHIR and Smile CDR define a special type of SearchParameter called a Combo Search Index Parameter that is used to index a combination of parameters together in a single database table. For example, consider the following search: http://localhost:8000/Patient?family=smith&gender=http://hl7.org/fhir/administrative-gender|male&birthdate=2021-01-01

By default, the search above relies on separate index tables to manage the family name, gender, and birthdate parameters. This generally works well, but can lead to performance issues if each of these parameters individually returns a large number of records (as would likely be the case for the family and gender parameters above in a large FHIR repository).

Using a Combo Search Index Parameter avoids unnecessary database joining by combining (denormalizing) all of the above values into a single database table for indexing and searching. Optionally, Smile CDR can also enforce uniqueness for the values of the parameters. See Unique Combo Search Index Parameters below for more information.

5.5.2Composite vs Combo Search Index Parameters

 

Note that Combo Search Index Parameters are a different concept from the FHIR Composite Search Parameter type.

FHIR Composite Search Index Parameters use a single parameter in a REST search URL to express multiple values where the values are closely related within the resource (e.g. the component code and component value within an Observation).

HAPI FHIR / Smile CDR Combo Index Search Parameters use multiple parameters in a REST search URL to express unrelated search parameters that are intended to be used together.

Both of these concepts are defined using a SearchParameter resource with a type of composite, however the latter uses an sp-unique extension to mark it as a combo search parameter.

There are limited number of Search Parameter types that can be used in composite and combo Search Parameters. For more details see Support for Component Types.

5.5.3Example

 

The following example shows a sample Non-unique Combo Index Search parameter and it assumes that you have already created the 3 individual SearchParameter resources based on the Patient resource's properties being used here (family, gender and birthdate) :

{
  "resourceType": "SearchParameter",
  "extension": [
    {
      "url": "http://hapifhir.io/fhir/StructureDefinition/sp-unique",
      "valueBoolean": false
    }
  ],
  "status": "active",
  "code": "family-gender-birthdate",
  "base": [
    "Patient"
  ],
  "type": "composite",
  "expression": "Patient",
  "component": [
    {
      "definition": "SearchParameter/individual-family",
      "expression": "Patient"
    },
    {
      "definition": "SearchParameter/individual-gender",
      "expression": "Patient"
    },
    {
      "definition": "SearchParameter/individual-birthdate",
      "expression": "Patient"
    }
  ]
}

5.5.4Support for Component Types

 

Composite and Combo SearchParameters are composed of other SearchParameters which are listed under the component element of the SearchParameter. Smile CDR and HAPI FHIR support subsets of SearchParameterTypes for composed SearchParameters which will differ based on the containing SearchParameter definition (see sp_unique extension) and whether Indexing of Search Parameters is enabled.

The following table lists supported Types for contained SearchParameters based on the containing composed SearchParameter. Note the limitations described in the following section as well.

Containing composed SP / Contained SP TypeStringTokenDateQuantityUriNumberReference
Combo Unique
Combo Non-Unique
Composite with full text indexing
Composite without full text indexing

5.5.4.1Limitations

  • Partitioning: Unique Combo search parameters are not partition-aware. This means that uniqueness will be enforced globally (i.e. not on a per-partition basis) and the uniqueness constraint on the HFJ_IDX_CMP_STRING_UNIQ table does not incorporate the partition ID.
  • Token: Tokens will only be indexed if the element value includes both a system and a value, except in cases where the system is implicit because the element is of type code and has a required terminology binding (e.g. Patient.gender).
  • Date/Time:
    • For Combo Non-Unique search parameters, Date and DateTime types will only be indexed if the date has DAY precision (i.e. yyyy-MM-dd).
    • Combo Unique search index is not used during the search if one of the component search parameters has a Date or DateTime type; in this case, index is only used to enforce uniqueness.
  • Reference: References will only be indexed if the element value is exactly in the form [resourceType]/[id]. Searches will only leverage the index if the search URL is also in this exact form.