Hi, Praveen.

`OpenSearch supports writing data in the JSON format, but in Flink its default 
data format is Avro JSON.`
I'm not sure what is the ` Avro JSON` means. In Opensearch connector, there are 
multi formats it supports sucn as "avro", "format" and etc by adding 
corresponding jars, and the default format[1] is "json" you want.


`OpenSearch Java Rest Client support writing the Java object directly to the 
openSearch using the below code.`
Currently,  the Opensearch connector connector always write the data 
serialized[2]. You can modify here directly in Opensearch connector, re-package 
it and try to use it.


[1] 
https://github.com/apache/flink-connector-opensearch/blob/ab36cebc12db3aa0fa9df8a770b1845a78afe5bf/flink-connector-opensearch/src/main/java/org/apache/flink/connector/opensearch/table/OpensearchConnectorOptions.java#L136
[2] 
https://github.com/apache/flink-connector-opensearch/blob/ab36cebc12db3aa0fa9df8a770b1845a78afe5bf/flink-connector-opensearch/src/main/java/org/apache/flink/connector/opensearch/table/RowOpensearchEmitter.java#L110C32-L110C45



--

    Best!
    Xuyang




At 2023-11-21 13:32:35, "Praveen Chandna via user" <user@flink.apache.org> 
wrote:

Hello Team

 

Please helps to answer the below query.

 

OpenSearch supports writing data in the JSON format, but in Flink its default 
data format is Avro JSON. What is the best practice to write data to Open 
Search using Flink OpenSearch Connector? Do we need to manually convert Avro 
JSON to JSON format or is there any in-built support in Flink to write JSON to 
openSearch.
How can I write the existing complex nested JSON data into OpenSearch using the 
Flink connector rather than writing each key-value(or filed/value).
OpenSearch Java Rest Client support writing the Java object directly to the 
openSearch using the below code.

 

IndexRequest<UserDataObject> indexRequest =new 
IndexRequest.Builder<UserDataObject>().index(index).document(indexData).build();

 

https://opensearch.org/docs/latest/clients/java/

 

Thanks !!

 

// Regards

Praveen Chandna

 

Reply via email to