[jira] [Created] (FLINK-13519) Elasticsearch Connector sample code for Scala on version 6.x will not work

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-13519) Elasticsearch Connector sample code for Scala on version 6.x will not work

Shang Yuanchun (Jira)
Alberto Romero created FLINK-13519:
--------------------------------------

             Summary: Elasticsearch Connector sample code for Scala on version 6.x will not work
                 Key: FLINK-13519
                 URL: https://issues.apache.org/jira/browse/FLINK-13519
             Project: Flink
          Issue Type: Bug
          Components: Documentation
    Affects Versions: 1.8.1, 1.8.0, 1.7.2
            Reporter: Alberto Romero


The Scala example in the documentation for the Elasticsearch Connector, version 6.x, will not work. The class ElasticsearchSinkFunction[String] requires a RuntimeContext and a RequestIndexer, which the example omits.

Also, *_type_* needs to be in inverse quotes as it's a Scala keyword.

It should look like the following:
{code:java}
def process(element: String, ctx: RuntimeContext, indexer: RequestIndexer) {
   val json = new java.util.HashMap[String, String]
   json.put("data", element)

   val rqst: IndexRequest = Requests.indexRequest
      .index("testarindex")
      .`type`("_doc")
      .source(json)

   indexer.add(rqst)
}{code}
 



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)