- X-Pack Reference for 6.0-6.2 and 5.x:
- Introduction
- Setting Up X-Pack
- Breaking Changes
- X-Pack APIs
- Graphing Connections in Your Data
- Profiling your Queries and Aggregations
- Reporting from Kibana
- Securing the Elastic Stack
- Getting Started with Security
- How Security Works
- Setting Up User Authentication
- Configuring SAML Single-Sign-On on the Elastic Stack
- Configuring Role-based Access Control
- Auditing Security Events
- Encrypting Communications
- Restricting Connections with IP Filtering
- Cross Cluster Search, Tribe, Clients and Integrations
- Reference
- Monitoring the Elastic Stack
- Alerting on Cluster and Index Events
- Machine Learning in the Elastic Stack
- Troubleshooting
- Getting Help
- X-Pack security
- Can’t log in after upgrading to 6.2.4
- Some settings are not returned via the nodes settings API
- Authorization exceptions
- Users command fails due to extra arguments
- Users are frequently locked out of Active Directory
- Certificate verification fails for curl on Mac
- SSLHandshakeException causes connections to fail
- Common SSL/TLS exceptions
- Internal Server Error in Kibana
- Setup-passwords command fails due to connection failure
- X-Pack Watcher
- X-Pack monitoring
- X-Pack machine learning
- Limitations
- License Management
- Release Notes
WARNING: Version 6.2 of the Elastic Stack has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Search Transform
editSearch Transform
editA Transform that executes a search on the cluster and replaces the current payload in the watch execution context with the returned search response. The following snippet shows how a simple search transform can be defined on the watch level:
{ "transform" : { "search" : { "request" : { "body" : { "query" : { "match_all" : {} }} } } } }
Like every other search based construct, one can make use of the full search
API supported by Elasticsearch. For example, the following search transform
execute a search over all events indices, matching events with error
priority:
{ "transform" : { "search" : { "request" : { "indices" : [ "events-*" ], "body" : { "size" : 0, "query" : { "match" : { "priority" : "error"} } } } } } }
The following table lists all available settings for the search transform:
Table 34. Search Transform Settings
Name | Required | Default | Description |
---|---|---|---|
|
no |
query_then_fetch |
The search type. |
|
no |
all indices |
One or more indices to search on. |
|
no |
all types |
One or more document types to search on (may be a comma-delimited string or an array of document types names) |
|
no |
|
The body of the request. The
request body follows
the same structure you normally send in the body of
a REST |
|
no |
|
Determines how to expand indices wildcards. Can be one
of |
|
no |
|
A boolean value that determines whether the search should leniently ignore unavailable indices (see multi-index support) |
|
no |
|
A boolean value that determines whether the search should leniently return no results when no indices are resolved (see multi-index support) |
|
no |
- |
The body of the search template. See configure templates for more information. |
|
no |
30s |
The timeout for waiting for the search api call to return. If no response is returned within this time, the search transform times out and fails. This setting overrides the default timeouts. |
Template Support
editThe search transform support mustache templates. This can either be as part of the body definition, or alternatively, point to an existing template (either defined in a file or registered as a script in Elasticsearch).
For example, the following snippet shows a search that refers to the scheduled time of the watch:
{ "transform" : { "search" : { "request" : { "indices" : [ "logstash-*" ], "types" : [ "event" ], "body" : { "size" : 0, "query" : { "bool" : { "must" : { "match" : { "priority" : "error"} }, "filter" : [ { "range" : { "@timestamp" : { "from" : "{{ctx.trigger.scheduled_time}}||-30s", "to" : "{{ctx.trigger.triggered_time}}" } } } ] } } } } } } }
The model of the template is a union between the provided template.params
settings and the standard watch execution context model.
The following is an example of using templates that refer to provided parameters:
{ "transform" : { "search" : { "request" : { "indices" : [ "logstash-*" ], "types" : [ "event" ], "template" : { "source" : { "size" : 0, "query" : { "bool" : { "must" : { "match" : { "priority" : "{{priority}}"} }, "filter" : [ { "range" : { "@timestamp" : { "from" : "{{ctx.trigger.scheduled_time}}||-30s", "to" : "{{ctx.trigger.triggered_time}}" } } } ] } }, "params" : { "priority" : "error" } } } } } } }
On this page
ElasticON events are back!
Learn about the Elastic Search AI Platform from the experts at our live events.
Register now