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


##########
solr/core/src/java/org/apache/solr/request/SolrQueryRequest.java:
##########
@@ -39,6 +40,39 @@
  */
 public interface SolrQueryRequest extends AutoCloseable {
 
+  /** This is the solr.xml parameter for {@link 
#ALLOW_PARTIAL_RESULTS_DEFAULT} */
+  String SOLR_ALLOW_PARTIAL_RESULTS_DEFAULT = 
"solr.allowPartialResultsDefault";
+
+  /**
+   * Users can set {@link SolrQueryRequest#SOLR_ALLOW_PARTIAL_RESULTS_DEFAULT} 
system property to
+   * true, and solr will fail requests where any shard fails due query 
exedution limits (time, cpu
+   * etc). Setting this will prevent solr from collecting partial results by 
default, adding
+   * performance in applications where partial results are not typically 
useful. This setting can be
+   * overridden (in either direction) on a per-request basis with 
&allowPartialResults=false
+   */
+  boolean ALLOW_PARTIAL_RESULTS_DEFAULT = 
Boolean.getBoolean(SOLR_ALLOW_PARTIAL_RESULTS_DEFAULT);
+
+  /**
+   * Tests if the partials for the request should be discarded. Examines {@link
+   * SolrQueryRequest#ALLOW_PARTIAL_RESULTS_DEFAULT} from solr.xml (which may 
be influenced by
+   * system property or ENV var and also examines {@link 
CommonParams#ALLOW_PARTIAL_RESULTS} request
+   * param. The Request Parameter takes precedence if both are set.
+   *
+   * <p>Note: A default solr.xml from the distribution actively sets the 
default to true in absence
+   * of a system prop or env var to the contrary.
+   *
+   * @return true if partials should be discarded.
+   * @param params the request parameters
+   */
+  static boolean shouldDiscardPartials(SolrParams params) {
+    Boolean userParamAllowPartial = 
params.getBool(CommonParams.ALLOW_PARTIAL_RESULTS);
+    if (userParamAllowPartial != null) {
+      return !userParamAllowPartial;
+    } else {
+      return ALLOW_PARTIAL_RESULTS_DEFAULT;
+    }

Review Comment:
   can we use the overloaded version of getBool that provides a default?  We'd 
then have a one-liner here.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to