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


##########
components/camel-solr/src/main/java/org/apache/camel/component/solr/SolrProducer.java:
##########
@@ -175,58 +176,66 @@ public SolrClient getSolrClient() {
     }
 
     private SolrOperation resolveSolrOperation(Exchange exchange, boolean 
hasSolrParams) {
-        // Operation can be driven by either (in order of preference):
-        // a. If the body is a specific class (SolrQuery, QueryRequest, 
UpdateRequest, SolrInputDocument(=Map)).
-        // b. If the body is not one of the specific classes, the operation is 
set by the
-        // header if it exists.
-        // c. If neither the operation can not be derived from the body or
-        // header, the configuration is used.
-        // In the event we can't discover the operation from a, b or c we throw
-        // an error.
+        // The operation is, in this order:
+        // a. the operation of a body that is a request of SolrJ, which the 
route builds (SolrPing, SolrQuery,
+        // QueryRequest, UpdateRequest), or none for another SolrRequest, 
which is sent as it is;
+        // b. the operation of the header, or else of the configuration;
+        // c. derived from the body, when neither is set: the query string 
header searches, a Map or a file inserts, and
+        // a collection inserts, or deletes by id when it holds strings. The 
body is the data of the message, so it never
+        // changes the operation that the header or the configuration names.
+        // In the event we can't discover the operation from a, b or c we 
throw an error.
 
-        Object body = exchange.getMessage().getBody();
+        Message message = exchange.getMessage();
+        Object body = message.getBody();
         if (ObjectHelper.isNotEmpty(body)) {
             LOG.debug("Operation request body: {}", body);
         }
         if (body instanceof SolrPing) {
             return SolrOperation.PING;
         }
-        if (body instanceof SolrQuery
-                || body instanceof QueryRequest
-                || 
exchange.getMessage().getHeader(SolrConstants.PARAM_QUERY_STRING) != null) {
+        if (body instanceof SolrQuery || body instanceof QueryRequest) {
             return SolrOperation.SEARCH;
         }
-        if (body instanceof Map
-                || body instanceof WrappedFile
-                || body instanceof File
-                || body instanceof UpdateRequest) {
+        if (body instanceof UpdateRequest) {
             return SolrOperation.INSERT;

Review Comment:
   💡 **Nit:** `UpdateRequest` is a subclass of `SolrRequest`, so this check is 
the specific-before-general case for it. A brief comment here (e.g. `// 
UpdateRequest is a SolrRequest but maps to INSERT`) would make it immediately 
clear why `UpdateRequest` is singled out rather than falling through to the 
`return null` below.



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