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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
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.com.fasterxml.jackson.databind.JsonNode
extractJsonNode
(org.apache.pulsar.client.api.Schema<?> schema, Object val) void
open
(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.JsonNode
stripNullNodes
(com.fasterxml.jackson.databind.JsonNode node) void
write
(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:
close
in 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 com.fasterxml.jackson.databind.JsonNode extractJsonNode(org.apache.pulsar.client.api.Schema<?> schema, Object val) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-