Problems while using _bulk api via camel rest route

Message History (source location and message history is disabled)

Source ID Processor Elapsed (ms)
route1/route1 from[timer://first-timer] 7943647
...
route1/to1 rest:post:/_bulk 0

Stacktrace

org.apache.camel.http.base.HttpOperationFailedException: HTTP operation failed invoking http://localhost:9200/_bulk with statusCode: 400
at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:422) ~[camel-http-3.20.5.jar:3.20.5]
at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:294) ~[camel-http-3.20.5.jar:3.20.5]
at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:66) ~[camel-support-3.20.5.jar:3.20.5]
at org.apache.camel.component.rest.RestProducer.process(RestProducer.java:83) ~[camel-rest-3.20.5.jar:3.20.5]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:172) ~[camel-core-processor-3.20.5.jar:3.20.5]
at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477) ~[camel-core-processor-3.20.5.jar:3.20.5]
at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:181) ~[camel-base-engine-3.20.5.jar:3.20.5]
at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59) ~[camel-base-engine-3.20.5.jar:3.20.5]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:165) ~[camel-core-processor-3.20.5.jar:3.20.5]
at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:392) ~[camel-base-engine-3.20.5.jar:3.20.5]
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210) ~[camel-timer-3.20.5.jar:3.20.5]
at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76) ~[camel-timer-3.20.5.jar:3.20.5]
at java.base/java.util.TimerThread.mainLoop(Timer.java:566) ~[na:na]
at java.base/java.util.TimerThread.run(Timer.java:516) ~[na:na]

2023-06-16 09:28:06.502 WARN 32000 --- [r://first-timer] o.a.camel.component.timer.TimerConsumer : Error processing exchange. Exchange[458FCA3ACF100D6-0000000000000005]. Caused by: [org.apache.camel.http.base.HttpOperationFailedException - HTTP operation failed invoking http://localhost:9200/_bulk with statusCode: 400]

org.apache.camel.http.base.HttpOperationFailedException: HTTP operation failed invoking http://localhost:9200/_bulk with statusCode: 400

bulkRequest :
String bulkRequest = "{"index": {"_index": "" + index + "", "_type": "" + type + ""}}\n" +
"{"field1": "value1"}\n" +
"{"index": {"_index": "" + index + "", "_type": "" + type + ""}}\n" +
"{"field2": "value2"}\n";

Which version of Elasticsearch are you using? Document types have been deprecated so if you are indexing into a recent version you may want to remove the type as shown in the docs.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.