Skip to content

Latest commit

 

History

History
83 lines (49 loc) · 3.27 KB

configure-search-api.md

File metadata and controls

83 lines (49 loc) · 3.27 KB

Configure Search API

Aidbox Search API can be configured in many ways. This page explains the difference between general types of Search API.

Jsonpath vs jsonknife

Aidbox has two engines to search: jsonpath and jsonknife.

The engine is responsible for SQL generation for search operations. SQL by jsonpath and jsonknife is different for search parameter types: date, number, quantity, reference, string, token, uri. _lastUpdated, _createdAt search parameters and :missing modifier searches also differ by engine.

jsonpath-engine:

  • supported by PostgreSQL without external extensions, can be used with managed PostgreSQL, e.g. Azure PostgreSQL
  • better performance for string search parameters and all string-related search (e.g. :text modifier)*
  • will be supported as main engine

jsonknife:

  • better performance for dates, number and quantity search parameters*

*using indexes makes performance approximately the same

Set engine

Use BOX_SEARCH_ENGINE environment variable to choose the engine. The default is knife.

BOX_SEARCH_ENGINE="jsonpath" # or "knife"

Zen Search

zen-lang is a powerful DSL language that can configure Aidbox, validate profiles, and search. It allows you to automatically set up search parameters from IGs and make your own search parameters and associated indexes.

How to configure zen-search?

To enable zen-search, use BOX_SEARCH_ZEN__FHIR=true and BOX_SEARCH_RESOURCE__COMPAT=false to use the preferred version of zen-search (backward compatibility environment variable).

BOX_SEARCH_ZEN__FHIR=true
BOX_SEARCH_RESOURCE__COMPAT=false # default is true

How to make my Zen Search Parameter in the configuration project?

Follow this guide.

Indexes for SearchParameters

You can also auto-generate indexes for SearchParameter:

{% content-ref url="../../../storage-1/indexes/" %} indexes {% endcontent-ref %}

Preferred operator

Token and Reference search parameters use exact match.

Aidbox uses Postgres @> operator for this type of searches. The @> operator is the containment operator. It checks that FHIR resource contains some subresource.

The main advantage of the @> operator is that the single GIN index covers all token and reference searches. However sometimes Postgres planner can not build effecient query plan.

Alternatively in some cases it is possible to extract value directly using #>> operator. This operator extracts value from the given path. There is a limitation: path must not contain any arrays.

You can configure Aidbox to prefer #>> operator to @> operator using the environment variable

box_search_token__operator

or using path

[:search :token-operator]

in Aidbox configuration project config zen symbol.

Possible values are:

  • @>: use the @> operator always
  • #>>: use the #>> operator when possible, @> otherwise