Class ElasticSearchSink
java.lang.Object
org.apache.pulsar.io.elasticsearch.ElasticSearchSink
- All Implemented Interfaces:
AutoCloseable,Sink<org.apache.pulsar.client.api.schema.GenericObject>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()extractIdAndDocument(org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) Extract ES _id and _source using the Schema if available.static com.fasterxml.jackson.databind.JsonNodeextractJsonNode(org.apache.pulsar.client.api.Schema<?> schema, Object val) voidopen(Map<String, Object> config, SinkContext sinkContext) stringify(com.fasterxml.jackson.databind.JsonNode jsonNode) stringifyKey(com.fasterxml.jackson.databind.JsonNode jsonNode) Convert a JsonNode to an Elasticsearch id.stringifyKey(com.fasterxml.jackson.databind.JsonNode jsonNode, List<String> fields) stringifyKey(org.apache.pulsar.client.api.Schema<?> schema, Object val) stringifyValue(org.apache.pulsar.client.api.Schema<?> schema, Object val) static com.fasterxml.jackson.databind.JsonNodestripNullNodes(com.fasterxml.jackson.databind.JsonNode node) voidwrite(org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record)
-
Constructor Details
-
ElasticSearchSink
public ElasticSearchSink()
-
-
Method Details
-
open
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
write
public void write(org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) throws Exception -
extractIdAndDocument
public org.apache.commons.lang3.tuple.Pair<String,String> extractIdAndDocument(org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) throws com.fasterxml.jackson.core.JsonProcessingException Extract ES _id and _source using the Schema if available.- Parameters:
record-- Returns:
- A pair for _id and _source
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
stringifyKey
public String stringifyKey(org.apache.pulsar.client.api.Schema<?> schema, Object val) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
stringifyKey
public String stringifyKey(com.fasterxml.jackson.databind.JsonNode jsonNode) throws com.fasterxml.jackson.core.JsonProcessingException Convert a JsonNode to an Elasticsearch id.- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
stringifyKey
public String stringifyKey(com.fasterxml.jackson.databind.JsonNode jsonNode, List<String> fields) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
stringifyValue
public String stringifyValue(org.apache.pulsar.client.api.Schema<?> schema, Object val) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
stringify
public String stringify(com.fasterxml.jackson.databind.JsonNode jsonNode) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
stripNullNodes
public static com.fasterxml.jackson.databind.JsonNode stripNullNodes(com.fasterxml.jackson.databind.JsonNode node) -
extractJsonNode
public static com.fasterxml.jackson.databind.JsonNode extractJsonNode(org.apache.pulsar.client.api.Schema<?> schema, Object val)
-