Skip to content

Apache Lucene open-source search software

Only create a Filter list if there is a non-empty fq parameter

Simon Willnauera7a9be923ec5
diff --git a/solr/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/src/java/org/apache/solr/handler/component/QueryComponent.java
index f98d65493ca..10049937917 100644
--- a/solr/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -107,7 +107,6 @@ public class QueryComponent extends SearchComponent
List<Query> filters = rb.getFilters();
if (filters==null) {
filters = new ArrayList<Query>(fqs.length);
- rb.setFilters( filters );
}
for (String fq : fqs) {
if (fq != null && fq.trim().length()!=0) {
@@ -115,6 +114,12 @@ public class QueryComponent extends SearchComponent
filters.add(fqp.getQuery());
}
}
+ // only set the filters if they are not empty otherwise
+ // fq=&someotherParam= will trigger all docs filter for every request
+ // if filter cache is disabled
+ if (!filters.isEmpty()) {
+ rb.setFilters( filters );
+ }
}
} catch (ParseException e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);