davsclaus commented on code in PR #28398:
URL: https://github.com/apache/camel/pull/28398#discussion_r4367550727


##########
components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientEndpoint.java:
##########
@@ -36,6 +39,50 @@
              title = "Elasticsearch Low level Rest Client",
              syntax = "elasticsearch-rest-client:clusterName", producerOnly = 
true,
              category = { Category.SEARCH }, headersClass = 
ElasticSearchRestClientConstant.class)
+@BodyTypes(producerIn = @BodyType(value = {
+        Carrier.TEXT, Carrier.BYTES, Carrier.STREAM, Carrier.FILE, 
Carrier.VALUE, Carrier.MAP, Carrier.NULL },
+                                  byOption = {
+                                          @BodyType.When(option = "operation", 
value = "INDEX_OR_UPDATE",
+                                                         carriers = {
+                                                                 Carrier.TEXT, 
Carrier.BYTES, Carrier.STREAM, Carrier.FILE }),
+                                          @BodyType.When(option = "operation", 
value = "GET_BY_ID",
+                                                         carriers = { 
Carrier.TEXT, Carrier.VALUE, Carrier.NULL }),
+                                          @BodyType.When(option = "operation", 
value = "DELETE",
+                                                         carriers = { 
Carrier.TEXT, Carrier.VALUE, Carrier.NULL }),
+                                          @BodyType.When(option = "operation", 
value = "SEARCH",
+                                                         carriers = { 
Carrier.MAP, Carrier.NULL }),
+                                          @BodyType.When(option = "operation", 
value = "CREATE_INDEX", carriers = Carrier.ANY),
+                                          @BodyType.When(option = "operation", 
value = "DELETE_INDEX",
+                                                         carriers = 
Carrier.ANY) },
+                                  description = "By the operation, set by the 
operation option or the CamelElasticsearchOperation"
+                                                + " header. INDEX_OR_UPDATE 
sends the body as the JSON document: text, bytes, a"
+                                                + " stream or a file of it; a 
Map or a POJO is sent as its toString() and"
+                                                + " fails, so marshal it to 
JSON first. GET_BY_ID and DELETE take the id as"
+                                                + " the body, or from the 
CamelElasticsearchId header when the body is empty."
+                                                + " SEARCH takes a Map of 
field names and values to match, or else the JSON"
+                                                + " query of the 
CamelElasticsearchSearchQuery header; a JSON text body is"
+                                                + " not used, and with neither 
all documents match. CREATE_INDEX and"
+                                                + " DELETE_INDEX do not use 
the body: the settings of a new index are in the"
+                                                + " 
CamelElasticsearchIndexSettings header"),
+           producerOut = @BodyType(value = { Carrier.TEXT, Carrier.VALUE },
+                                   byOption = {
+                                           @BodyType.When(option = 
"operation", value = "INDEX_OR_UPDATE",
+                                                          carriers = 
Carrier.TEXT, javaType = "java.lang.String"),
+                                           @BodyType.When(option = 
"operation", value = "GET_BY_ID", carriers = Carrier.TEXT,
+                                                          javaType = 
"java.lang.String"),

Review Comment:
   Thanks. The `null` branch of `extractDocument()` is not reached for a 
missing id: Elasticsearch answers a GET of a missing document with 404, and the 
low-level `RestClient` (9.5.5) fails every response of 300 or more whose status 
is not in the request's ignore set. The producer sets no ignore set, so the 
exchange fails with a `ResponseException` and the body never becomes `null`. 
Adding `Carrier.NULL` would then promise something that does not happen.
   
   The description did leave the GET_BY_ID case unclear, though. b5cbb8c3d69c 
now says: "a GET_BY_ID of a missing id fails with 404 rather than giving null".
   
   _Claude Code on behalf of davsclaus_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to