Elasticsearch source connector

Description

Used to read data from Elasticsearch.

support version >= 2.x and <= 8.x.

Key features

Options

name type required default value
hosts array yes -
username string no -
password string no -
index string yes -
source array no -
query json no {“match_all”: {}}
scroll_time string no 1m
scroll_size int no 100
tls_verify_certificate boolean no true
tls_verify_hostnames boolean no true
array_column map no
tls_keystore_path string no -
tls_keystore_password string no -
tls_truststore_path string no -
tls_truststore_password string no -
common-options no -

hosts [array]

Elasticsearch cluster http address, the format is host:port, allowing multiple hosts to be specified. Such as ["host1:9200", "host2:9200"].

username [string]

x-pack username.

password [string]

x-pack password.

index [string]

Elasticsearch index name, support * fuzzy matching.

source [array]

The fields of index. You can get the document id by specifying the field _id.If sink _id to other index,you need specify an alias for _id due to the Elasticsearch limit. If you don’t config source, it is automatically retrieved from the mapping of the index.

array_column [array]

The fields of array type. Since there is no array index in es,so need assign array type,just like {c_array = "array<tinyint>"}.

query [json]

Elasticsearch DSL. You can control the range of data read.

scroll_time [String]

Amount of time Elasticsearch will keep the search context alive for scroll requests.

scroll_size [int]

Maximum number of hits to be returned with each Elasticsearch scroll request.

tls_verify_certificate [boolean]

Enable certificates validation for HTTPS endpoints

tls_verify_hostname [boolean]

Enable hostname validation for HTTPS endpoints

tls_keystore_path [string]

The path to the PEM or JKS key store. This file must be readable by the operating system user running SeaTunnel.

tls_keystore_password [string]

The key password for the key store specified

tls_truststore_path [string]

The path to PEM or JKS trust store. This file must be readable by the operating system user running SeaTunnel.

tls_truststore_password [string]

The key password for the trust store specified

common options

Source plugin common parameters, please refer to Source Common Options for details

Examples

simple

  1. Elasticsearch {
  2. hosts = ["localhost:9200"]
  3. index = "seatunnel-*"
  4. source = ["_id","name","age"]
  5. query = {"range":{"firstPacket":{"gte":1669225429990,"lte":1669225429990}}}
  6. }

complex

  1. Elasticsearch {
  2. hosts = ["elasticsearch:9200"]
  3. index = "st_index"
  4. schema = {
  5. fields {
  6. c_map = "map<string, tinyint>"
  7. c_array = "array<tinyint>"
  8. c_string = string
  9. c_boolean = boolean
  10. c_tinyint = tinyint
  11. c_smallint = smallint
  12. c_int = int
  13. c_bigint = bigint
  14. c_float = float
  15. c_double = double
  16. c_decimal = "decimal(2, 1)"
  17. c_bytes = bytes
  18. c_date = date
  19. c_timestamp = timestamp
  20. }
  21. }
  22. query = {"range":{"firstPacket":{"gte":1669225429990,"lte":1669225429990}}}
  23. }

SSL (Disable certificates validation)

  1. source {
  2. Elasticsearch {
  3. hosts = ["https://localhost:9200"]
  4. username = "elastic"
  5. password = "elasticsearch"
  6. tls_verify_certificate = false
  7. }
  8. }

SSL (Disable hostname validation)

  1. source {
  2. Elasticsearch {
  3. hosts = ["https://localhost:9200"]
  4. username = "elastic"
  5. password = "elasticsearch"
  6. tls_verify_hostname = false
  7. }
  8. }

SSL (Enable certificates validation)

  1. source {
  2. Elasticsearch {
  3. hosts = ["https://localhost:9200"]
  4. username = "elastic"
  5. password = "elasticsearch"
  6. tls_keystore_path = "${your elasticsearch home}/config/certs/http.p12"
  7. tls_keystore_password = "${your password}"
  8. }
  9. }

Changelog

next version

  • Add Elasticsearch Source Connector
  • [Feature] Support https protocol & compatible with opensearch (3997)
  • [Feature] Support DSL