gnodet-bot commented on code in PR #28398:
URL: https://github.com/apache/camel/pull/28398#discussion_r4367170930


##########
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:
   ⚠️ **Missing `Carrier.NULL` for `GET_BY_ID` output**
   
   The `ElasticsearchRestClientProducer.extractDocument()` returns `null` when 
`found == false` (document not found). The output body can therefore be `null`, 
but this is not reflected in the `carriers` list or the description.
   
   Suggested fix:
   ```suggestion
                                               @BodyType.When(option = 
"operation", value = "GET_BY_ID",
                                                              carriers = { 
Carrier.TEXT, Carrier.NULL },
                                                              javaType = 
"java.lang.String"),
   ```
   
   Also, the `description` should mention that `GET_BY_ID` returns `null` when 
the document is not found (the current text only says "gives the source of the 
document as JSON text" with no mention of the not-found case).



-- 
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