-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for executing queries based on pre-defined templates #4879
Comments
can we also support
this is much more readable? we can also make it super fast by using a new UPDATE: Also, based on above, I would go with
when in "string/bytes" mode, we can detect that, and its more readable. |
or
|
and
|
Makes sense - makes it also easier to simply copy/paste existing queries into templates. |
Adds support for storing mustache based query templates that can later be filled with query parameter values at execution time. Relates to elastic#4879
This makes the names of the parameters a template query accepts shorter and clearer. Relates to elastic#4879
As per suggestion in elastic#4879 modified the implementation to allow for templates that are not quoted but legitimate json. Leaving the option to completely quote in - needed anyway for support for referencing templates stored in the config directory. Relates to elastic#4879
Instead of digging out the number of hits use Elasticsearch provided helper method to check the hit count. (Thanks @spinscale for the suggestion) In addition simplify the test slightly by factoring index setup into separate method executed before test execution. Relates to elastic#4879
Relates to elastic#4879
When first moving mustache from shaded jar to lib dir the dependency to guava was missing... Relates to elastic#4879
Relates to elastic#4879 This moves mustache back to being shaded - having guava (which is a needed dependency of mustache) explicitly in the distribution files isn't an option: Used by too many projects and thus likely to cause version conflicts downstream. In addition this adds a rest test for the query templating feature.
Adds support for storing mustache based query templates that can later be filled with query parameter values at execution time. Templates may be both quoted, non-quoted and referencing templates stored in config/scripts/*.mustache by file name. See docs/reference/query-dsl/queries/template-query.asciidoc for templating examples. Implementation detail: mustache itself is being shaded as it depends directly on guava - so having it marked optional but included in the final distribution raises chances of version conflicts downstream. Fixes #4879
Relates to elastic#4879
Is it possible to create templates at runtime as opposed to pre-package them in the config folder ? |
@gedl yes - see template query and search template |
It would be nice to be able to store pre-defined query templates that can be referenced and filled with parameter values at query time. This can be in particular useful to be able to quickly replay queries with slightly different templates but identical parameter values e.g. in order to compare slightly different ways to formulate Elasticsearch queries wrt. runtime performance and actual results returned.
For developing and testing the template, both, template_string and template_vars can be submitted as part of the search request:
You register a template by storing it in the conf/scripts directory of
elasticsearch. In order to execute the stored template reference it in the query parameters:
Template language
Templating is based on Mustache. Substitution of tokens works as follows:
The text was updated successfully, but these errors were encountered: