Template-based Query Model
A query model using a template is wrapper around a templated Elasticsearch query. The template part here indicates that the model is a blueprint, that changes depending on the runtime values.
In the Query model editor, select Custom to create such a query model.
The Source index determines against which index the query is executed.
There are three tabs here: Template, Parameters and Preview.
Template
In this tab, the template for the query can be written.
A default example can be generated by clicking the Generate default template button.
Whether or not the query is safe can be set her. See the concepts page for more details.
The query itself needs to be compliant with the search query format of Elasticsearch, which is documented here: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html
The templating engine used by Flowable here is the Freemarker engine that has various options to conditionally include parts, format text in specific ways, has support for looping, etc. See more details here: https://freemarker.apache.org/index.html
Parameters
The parameters determine which values are available in the template.
For example defining a param1
will make that value available in the template, to write expressions such as
<#if param1??>,
or
"query": {
"bool": {
"must": [
{
"term": {
"variables.name": "accountNumber"
}
},
{
"match": {
"variables.numberValue": "{param1}"
}
}
]
}
More details around index structure and indexing general are available in the Indexing Guide.
Preview
The preview tab allows to test out the parameter bindings and see what the query would be when filling in specific values.