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


##########
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:
   Makes sense. Have changed the logic in such a way that it can be useful for 
other search components as well where a distributed request can be forced 
depending on the component requirement. 



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