pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

Elasticsearch 5.x Sink connector incompatible

Open jm7647 opened this issue 7 years ago • 5 comments

Describe the bug Works with ES 7.x version Fails with ES 5.x version

Didn't try other versions.

To Reproduce Steps to reproduce the behavior:

  1. Configure and run ES Sink
  2. See error

{"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [doc]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '', found: [_doc]"},"status":400} at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:705) ~[?:?] at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235) ~[?:?] at org.elasticsearch.client.RestClient.performRequest(RestClient.java:198) ~[?:?] at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:522) ~[?:?] at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:508) ~[?:?] at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:348) ~[?:?] at org.apache.pulsar.io.elasticsearch.ElasticSearchSink.write(ElasticSearchSink.java:91) ~[?:?] at org.apache.pulsar.functions.instance.JavaInstanceRunnable.sendOutputMessage(JavaInstanceRunnable.java:435) ~[org.apache.pulsar-pulsar-functions-instance-2.4.1.jar:?] at org.apache.pulsar.functions.instance.JavaInstanceRunnable.processResult(JavaInstanceRunnable.java:418) ~[org.apache.pulsar-pulsar-functions-instance-2.4.1.jar:?] at org.apache.pulsar.functions.instance.JavaInstanceRunnable.run(JavaInstanceRunnable.java:272) [org.apache.pulsar-pulsar-functions-instance-2.4.1.jar:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_212] Caused by: org.elasticsearch.client.ResponseException: method [POST], host [http://135.91.35.218:9200], URI [/eventslist/doc?timeout=1m], status line [HTTP/1.1 400 Bad Request] {"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '', found: [doc]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '', found: [_doc]"},"status":400}

Expected behavior

Screenshots

Desktop (please complete the following information):

  • OS: Ubuntu 16

Additional context

jm7647 avatar Nov 18 '19 22:11 jm7647

this probably requires another version of the connector should be part of a large discussion of managing the growing list of connectors.

aahmed-se avatar Nov 20 '19 23:11 aahmed-se

@tuteng to take a look

jiazhai avatar Nov 21 '19 03:11 jiazhai

I will find some time to test the relevant version. If there is any problem, I think we may need to provide special support. Such as developing a new connector for the corresponding version. If there are others who need this feature, please leave a message under this issue to let us know. Thank you.

tuteng avatar Dec 03 '19 03:12 tuteng

I have done some research in documents and some change histories of Elasticsearch, the problem is fundamentally related to the long term "removal of types" project in Elasticsearch.

In brief, Elasticsearch supported multiple types before 6.0. However, they found it to be a problematic abstraction, and decided to remove it gradually. The road map is to support only a single type start from 6.0, with the default type name set to be "_doc" since 6.2, and to support the type name "_doc" only(which will actually be considered as the name of the API endpoint rather than a type name) since 7.0, and finally remove the concept of type since 8.0, while "_doc" will be kept in the document APIs to make them backward compatible.

On the other hand, names with a leading underscore are generally considered as reserved for internally use in Elasticsearch, and are not allowed to be used in user provided names (index, field, type, ...). And "_doc" is a special type name added in 6.2 to make the transition to 7.0 smoother, so it will not be supported before version 6.2.

As a result, "_doc" is supported as the only type name since 7.0 while not supported before 6.2, it is likely not possible to specify a default type name without knowing the version of the destination cluster(In fact, we have changed the type name from "doc" to "_doc" to support 7.0 in https://github.com/apache/pulsar/pull/4322).

To fix the issue, we can provide a configuration "typeName" with the default value set to be "_doc", so it supports versions of Elasticsearch since 6.2 by default, and can also support the previous versions if users configure a valid type name. Auto detection of the version of the cluster is possible but may not be very valuable for current feature sets.

fantapsody avatar Jan 10 '20 03:01 fantapsody

agree, configuration "typeName" would be a perfect solution.

jm7647 avatar Jan 10 '20 16:01 jm7647