**# HAPI FHIR JPA Lucene/Elasticsearch Indexing
The HAPI JPA Server supports optional indexing via Hibernate Search when configured to use Lucene or Elasticsearch.
This is required to support the
_text search parameters.
Additional indexing is implemented for simple search parameters of type token, string, and reference.
These implement the basic search, as well as several modifiers:
This experimental feature is enabled via the
setAdvancedLuceneIndexing() property of DaoConfig.
The Extended Lucene string search indexing supports the default search, as well as the modifiers defined in https://www.hl7.org/fhir/search.html#string.
:exactmatches the entire string, matching case and accents
:containsextends the default search to match any substring of the text
:textprovides a rich search syntax as using a modified Simple Query Syntax.
The Extended Lucene Indexing supports the default token search by code, system, or system+code,
as well as with the
:text modifier provides the same modified Simple Query Syntax used by string
:text search for token and string, Hapi provides a modified version of the Simple Query Syntax provided by Lucene and Elasticsearch.
Terms are delimited by whitespace, or query punctuation
"()|+'. Literal uses of these characters must be escaped by ''.
When the query only contains one or more bare terms, they are each converted to a prefix search to match the behaviour of a normal string search.
When multiple terms are present, they must all match (i.e.
OR behaviour use the
| operator between terms.
But if any special SQS syntax is active, the query is used as is.
To ensure that the query is used as-is, quote bare terms with the
" or character. E.g. `without any special syntax characters
|Fhir Query String||Executed Query||Matches||No Match||Note|
|Smit||Smit*||John Smith||John Smi|
|Jo Smit||Jo* Smit*||John Smith||John Frank||Multiple bare terms are |
|frank | john||frank | john||Frank Smith||Franklin Smith||SQS characters disable prefix wildcard|
|'frank'||'frank'||Frank Smith||Franklin Smith||Quoted terms are exact match|
The Extended Lucene Indexing supports the quantity search.
The Extended Lucene Indexing supports the URI search.
We support date searches using the eq, ne, lt, gt, ge, and le comparisons.
The Extended Lucene Indexing supports an extension of the
$expand operation on ValueSet with a new
contextDirection value of
existing. In this mode, the
context parameter is interpreted as a SearchParameter reference (by resource type and code), and the
filter is interpreted as a query token. The expansion will contain the most frequent
Coding values matching the filter.
E.g. the query
will return a ValueSet containing the most common values indexed under
Observation.code whose display text contains a word starting with "press", such as
http://loinc.org|8478-0 - "Mean blood pressure".
This extension is only valid at the type level, and requires that Extended Lucene Indexing be enabled.
As an experimental feature with the extended indexing, the full resource can be stored in the search index. This allows some queries to return results without using the relational database. Note: This does not support the $meta-add or $meta-delete operations. Full reindexing is required when this option is enabled after resources have been indexed.