dsmiley commented on code in PR #3418:
URL: https://github.com/apache/solr/pull/3418#discussion_r2334303365


##########
solr/core/src/java/org/apache/solr/handler/component/CombinedQuerySearchHandler.java:
##########
@@ -81,4 +88,33 @@ protected void postPrepareComponents(ResponseBuilder rb) {
       crb.propagate();
     }
   }
+
+  /**
+   * rb.distrib {@link ResponseBuilder} must be set for the combined query to 
work in case of single
+   * core standalone mode. This method set the parameter explicitly with other 
required solr param
+   * i.e. shards
+   *
+   * @param req the SolrQueryRequest
+   * @return boolean denoting whether the request can be marked as distributed.
+   */
+  @Override
+  protected boolean isDistrib(SolrQueryRequest req) {
+    boolean isDistrib = super.isDistrib(req);
+    if (!isDistrib
+        && !req.getParams().getBool(ShardParams.IS_SHARD, false)
+        && req.getHttpSolrCall() != null) {
+      log.info("Configuring distributed mode to enable Combined Query.");
+      ModifiableSolrParams solrParams = new 
ModifiableSolrParams(req.getParams());
+      String scheme = req.getHttpSolrCall().getReq().getScheme();
+      String host = req.getHttpSolrCall().getReq().getServerName();
+      int port = req.getHttpSolrCall().getReq().getServerPort();
+      String context = req.getHttpSolrCall().getReq().getContextPath();
+      String core = req.getCore().getName();
+      String localShardUrl = String.format("%s://%s:%d%s/%s", scheme, host, 
port, context, core);
+      solrParams.set(ShardParams.SHARDS, localShardUrl);
+      req.setParams(solrParams);

Review Comment:
   It's not just standalone; a single shard collection will "short-circuit".  I 
was going to link to my same comment.  I understand the need/desire.  
Interestingly, this is the first component to want to prevent the short 
circuit, but I could see it being useful for any search component author who 
doesn't want the extra development cost of an optimized single-shard algorithm.
   
   Perhaps if SearchHandler called SearchComponent.prepare before it 
initialized ShardHandler (that latter part needs to know if short-circuit), 
then a component could add the short-circuit param.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to