Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

passing json in clob to elastic search as bulk index

vishnu prakashJun 25 2019

I have a requirement to post json data to elastic which is a  clob datatype ,Currently  i am using the package OS_COMMAND which executes linux commands from oracle , I tried to pass the data as below but getting error .Any suggestions to resolve or any approach is appreciated

Function

exec_CLOB(p_command in varchar2, p_stdin in clob) return clob

p_command as below

curl -s -u 'username:password' -XPOST "http://<url>/sample_test/_bulk" -H 'Content-Type: application/x-ndjson' -d @-'

p_stdin as below

{"index":{"_id":"1","_index":"sample_test"}}

{"patientId":"6220965944e044cda636aaa099488e1c","loaderMetadataId":"efeb7b014ce84fb982de61eb6df456d9","serviceName":"test"}

{"index":{"_id":"2","_index":"sample_test"}}

{"patientId":"6220965944e04dfgfg1c","loaderMetadataId":"efeb7b014ce84fb982de61eb6df456d9","serviceName":"test"}

'

Error

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"}],"type":"illegal_argument_exception","reason":"The bulk request must be terminated by a newline [\\n]"},"status":400}

I have even tried to append \n for each lines of json ..still its giving me the error

Comments
Post Details
Added on Jun 25 2019
0 comments
404 views