Skip to content

Query Filters

Query filters allow you to describe search query modifications declaratively. It is possible to filter, sort, paginate and build facets using query filters.

Let's describe our new document:


Now we can describe query filters for the BikeDoc:


To apply it to a search query you need query filter parameters. They are just a mapping where keys are a pair of filter name and an operation, and values are a list of strings. For example, it could be transformed from http query parameters.


After executing query we are able to process its results:


Run a full-fledged query filters sample

JVM version:

./gradlew :samples:runBikeshop -q --console=plain

Native version:

./gradlew :samples:linkBikeshopDebugExecutableNative
./samples/build/bin/native/bikeshopDebugExecutable/bikeshop.kexe

Both versions support following environment variables:

  • ELASTIC_URL - URL to your Elasticsearch cluster. Default is http://localhost:9200. If you want to use TLS change it to https://localhost:9200. Elasticsearch 8.x and Opensearch 2.x turn on TLS by default.
  • ELASTIC_USER - user for a basic authentication. Default is elastic. Change it to admin if you use Opensearch.
  • ELASTIC_PASSWORD - if this variable is set, basic authentication will be used. Set it to a real password of your cluster or leave empty if your cluster doesn't require authentication. Password for default configuration of Elasticsearch 8.x can be found in logs. Default password for Opensearch 2.x is admin.