HoustonPutman commented on code in PR #1450:
URL: https://github.com/apache/solr/pull/1450#discussion_r1156086732


##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -716,23 +723,42 @@ public QueryResult search(QueryResult qr, QueryCommand 
cmd) throws IOException {
     return qr;
   }
 
-  // FIXME: This option has been dead/noop since 3.1, should we re-enable or 
remove it?
-  // public Hits search(Query query, Filter filter, Sort sort) throws 
IOException {
-  // // todo - when Solr starts accepting filters, need to
-  // // change this conditional check (filter!=null) and create a new filter
-  // // that ANDs them together if it already exists.
-  //
-  // if (optimizer==null || filter!=null || !(query instanceof BooleanQuery)
-  // ) {
-  // return super.search(query,filter,sort);
-  // } else {
-  // Query[] newQuery = new Query[1];
-  // Filter[] newFilter = new Filter[1];
-  // optimizer.optimize((BooleanQuery)query, this, 0, newQuery, newFilter);
-  //
-  // return super.search(newQuery[0], newFilter[0], sort);
-  // }
-  // }
+  @Override
+  protected void search(List<LeafReaderContext> leaves, Weight weight, 
Collector collector)
+      throws IOException {
+    final var queryTimeout = SolrQueryTimeoutImpl.getInstance();
+    if (useExitableDirectoryReader || queryTimeout.isTimeoutEnabled() == 
false) {
+      // no timeout.  Pass through to super class
+      super.search(leaves, weight, collector);
+    } else {
+      // Timeout enabled!  This impl is maybe a hack.  Use Lucene's 
IndexSearcher timeout.
+      // But only some queries have it so don't use on "this" 
(SolrIndexSearcher), not to mention
+      //   that timedOut() might race with concurrent queries (dubious design).
+      // So we need to make a new IndexSearcher instead of using "this".
+      new IndexSearcher(reader) { // cheap, actually!

Review Comment:
   Maybe we should open up a Lucene issue that gives us a search(...., timeout) 
method, so that this hack isn't necessary in the future. Though as you mention, 
that would include adding a similar TimeAllowedExceeded Exception to Lucene.



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