:plugin: elasticsearch
:type: input

///////////////////////////////////////////
START - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////
:version: %VERSION%
:release_date: %RELEASE_DATE%
:changelog_url: %CHANGELOG_URL%
:include_path: ../../../../logstash/docs/include
///////////////////////////////////////////
END - GENERATED VARIABLES, DO NOT EDIT!
///////////////////////////////////////////

[id="plugins-{type}-{plugin}"]

=== Elasticsearch input plugin

include::{include_path}/plugin_header.asciidoc[]

==== Description

.Compatibility Note
[NOTE]
================================================================================
Starting with Elasticsearch 5.3, there's an {ref}modules-http.html[HTTP setting]
called `http.content_type.required`. If this option is set to `true`, and you
are using Logstash 2.4 through 5.2, you need to update the Elasticsearch input
plugin to version 4.0.2 or higher.

================================================================================

Read from an Elasticsearch cluster, based on search query results.
This is useful for replaying test logs, reindexing, etc.

Example:
[source,ruby]
    input {
      # Read all documents from Elasticsearch matching the given query
      elasticsearch {
        hosts => "localhost"
        query => '{ "query": { "match": { "statuscode": 200 } }, "sort": [ "_doc" ] }'
      }
    }

This would create an Elasticsearch query with the following format:
[source,json]
    curl 'http://localhost:9200/logstash-*/_search?&scroll=1m&size=1000' -d '{
      "query": {
        "match": {
          "statuscode": 200
        }
      },
      "sort": [ "_doc" ]
    }'


[id="plugins-{type}s-{plugin}-options"]
==== Elasticsearch Input Configuration Options

This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.

[cols="<,<,<",options="header",]
|=======================================================================
|Setting |Input type|Required
| <<plugins-{type}s-{plugin}-ca_file>> |a valid filesystem path|No
| <<plugins-{type}s-{plugin}-docinfo>> |<<boolean,boolean>>|No
| <<plugins-{type}s-{plugin}-docinfo_fields>> |<<array,array>>|No
| <<plugins-{type}s-{plugin}-docinfo_target>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-hosts>> |<<array,array>>|No
| <<plugins-{type}s-{plugin}-index>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
| <<plugins-{type}s-{plugin}-query>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-scroll>> |<<string,string>>|No
| <<plugins-{type}s-{plugin}-size>> |<<number,number>>|No
| <<plugins-{type}s-{plugin}-ssl>> |<<boolean,boolean>>|No
| <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
|=======================================================================

Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
input plugins.

&nbsp;

[id="plugins-{type}s-{plugin}-ca_file"]
===== `ca_file` 

  * Value type is <<path,path>>
  * There is no default value for this setting.

SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary 

[id="plugins-{type}s-{plugin}-docinfo"]
===== `docinfo` 

  * Value type is <<boolean,boolean>>
  * Default value is `false`

If set, include Elasticsearch document information such as index, type, and
the id in the event.

It might be important to note, with regards to metadata, that if you're
ingesting documents with the intent to re-index them (or just update them)
that the `action` option in the elasticsearch output wants to know how to
handle those things. It can be dynamically assigned with a field
added to the metadata.

Example
[source, ruby]
    input {
      elasticsearch {
        hosts => "es.production.mysite.org"
        index => "mydata-2018.09.*"
        query => "*"
        size => 500
        scroll => "5m"
        docinfo => true
      }
    }
    output {
      elasticsearch {
        index => "copy-of-production.%{[@metadata][_index]}"
        document_type => "%{[@metadata][_type]}"
        document_id => "%{[@metadata][_id]}"
      }
    }


[id="plugins-{type}s-{plugin}-docinfo_fields"]
===== `docinfo_fields` 

  * Value type is <<array,array>>
  * Default value is `["_index", "_type", "_id"]`

List of document metadata to move to the `docinfo_target` field
To learn more about Elasticsearch metadata fields read
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_document_metadata.html

[id="plugins-{type}s-{plugin}-docinfo_target"]
===== `docinfo_target` 

  * Value type is <<string,string>>
  * Default value is `"@metadata"`

Where to move the Elasticsearch document information by default we use the @metadata field.

[id="plugins-{type}s-{plugin}-hosts"]
===== `hosts` 

  * Value type is <<array,array>>
  * There is no default value for this setting.

List of elasticsearch hosts to use for querying.
each host can be either IP, HOST, IP:port or HOST:port
port defaults to 9200

[id="plugins-{type}s-{plugin}-index"]
===== `index` 

  * Value type is <<string,string>>
  * Default value is `"logstash-*"`

The index or alias to search.

[id="plugins-{type}s-{plugin}-password"]
===== `password` 

  * Value type is <<password,password>>
  * There is no default value for this setting.

Basic Auth - password

[id="plugins-{type}s-{plugin}-query"]
===== `query` 

  * Value type is <<string,string>>
  * Default value is `"{ \"sort\": [ \"_doc\" ] }"`

The query to be executed. Read the Elasticsearch query DSL documentation
for more info
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

[id="plugins-{type}s-{plugin}-scroll"]
===== `scroll` 

  * Value type is <<string,string>>
  * Default value is `"1m"`

This parameter controls the keepalive time in seconds of the scrolling
request and initiates the scrolling process. The timeout applies per
round trip (i.e. between the previous scroll request, to the next).

[id="plugins-{type}s-{plugin}-size"]
===== `size` 

  * Value type is <<number,number>>
  * Default value is `1000`

This allows you to set the maximum number of hits returned per scroll.

[id="plugins-{type}s-{plugin}-ssl"]
===== `ssl` 

  * Value type is <<boolean,boolean>>
  * Default value is `false`

SSL

[id="plugins-{type}s-{plugin}-user"]
===== `user` 

  * Value type is <<string,string>>
  * There is no default value for this setting.

Basic Auth - username



[id="plugins-{type}s-{plugin}-common-options"]
include::{include_path}/{type}.asciidoc[]