Apache Lucene open-source search software
SOLR-14391: getDocSet(Query[]) can use search(query,collector) Refactoring to simplify SolrIndexSearcher. ScoreFilter interface is obsolete now. Fixed #1409
David Smileyf5d91395db21
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 00c17df53ed..3cb7fe9c4d1 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -164,6 +164,9 @@ Other Changesremoved from solr-core in favor of SolrNamedThreadFactory in solrj package and all solr-core classes now useSolrNamedThreadFactory. (Andras Salamon, shalin)+* SOLR-14391: Removed internal-ish ScoreFilter marker interface; only used by {!collapse}. Removed needless code in+ SolrIndexSearcher.getDocSet(List<Query>) (processes some filter queries). (David Smiley)+================== 8.5.1 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.javaindex 9114f3d7fa9..e7125772e33 100644--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java@@ -213,7 +213,7 @@ public class CollapsingQParserPlugin extends QParserPlugin {}}- public static class CollapsingPostFilter extends ExtendedQueryBase implements PostFilter, ScoreFilter {+ public static class CollapsingPostFilter extends ExtendedQueryBase implements PostFilter {private String collapseField;private final GroupHeadSelector groupHeadSelector;diff --git a/solr/core/src/java/org/apache/solr/search/ScoreFilter.java b/solr/core/src/java/org/apache/solr/search/ScoreFilter.javadeleted file mode 100644index f566ab1337a..00000000000--- a/solr/core/src/java/org/apache/solr/search/ScoreFilter.java+++ /dev/null@@ -1,21 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */-package org.apache.solr.search;--public interface ScoreFilter {--}\ No newline at end of filediff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex 8c5efae46e3..938d37c57af 100644--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -885,25 +885,6 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrIprivate static Comparator<Query> sortByCost = (q1, q2) -> ((ExtendedQuery) q1).getCost() - ((ExtendedQuery) q2).getCost();- private DocSet getDocSetScore(List<Query> queries) throws IOException {- Query main = queries.remove(0);- ProcessedFilter pf = getProcessedFilter(null, queries);- DocSetCollector setCollector = new DocSetCollector(maxDoc());- Collector collector = setCollector;- if (pf.postFilter != null) {- pf.postFilter.setLastDelegate(collector);- collector = pf.postFilter;- }-- search(QueryUtils.combineQueryAndFilter(main, pf.filter), collector);-- if (collector instanceof DelegatingCollector) {- ((DelegatingCollector) collector).finish();- }-- return DocSetUtil.getDocSet(setCollector, this);- }-/*** Returns the set of document ids matching all queries. This method is cache-aware and attempts to retrieve the* answer from the cache if possible. If the answer was not cached, it may have been inserted into the cache as a@@ -914,14 +895,6 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI*/public DocSet getDocSet(List<Query> queries) throws IOException {- if (queries != null) {- for (Query q : queries) {- if (q instanceof ScoreFilter) {- return getDocSetScore(queries);- }- }- }-ProcessedFilter pf = getProcessedFilter(null, queries);if (pf.postFilter == null) {@@ -939,43 +912,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrIcollector = pf.postFilter;}- for (final LeafReaderContext leaf : leafContexts) {- final LeafReader reader = leaf.reader();- Bits liveDocs = reader.getLiveDocs();- DocIdSet idSet = null;- if (pf.filter != null) {- idSet = pf.filter.getDocIdSet(leaf, liveDocs);- if (idSet == null) continue;- }- DocIdSetIterator idIter = null;- if (idSet != null) {- idIter = idSet.iterator();- if (idIter == null) continue;- if (!pf.hasDeletedDocs) liveDocs = null; // no need to check liveDocs- }-- final LeafCollector leafCollector = collector.getLeafCollector(leaf);- int max = reader.maxDoc();-- if (idIter == null) {- for (int docid = 0; docid < max; docid++) {- if (liveDocs != null && !liveDocs.get(docid)) continue;- leafCollector.collect(docid);- }- } else {- if (liveDocs != null) {- for (int docid = -1; (docid = idIter.advance(docid + 1)) < max; ) {- if (liveDocs.get(docid))- leafCollector.collect(docid);- }- } else {- for (int docid = -1; (docid = idIter.advance(docid + 1)) < max;) {- leafCollector.collect(docid);- }- }- }+ Query query = pf.filter != null ? pf.filter : matchAllDocsQuery;- }+ search(query, collector);if (collector instanceof DelegatingCollector) {((DelegatingCollector) collector).finish();@@ -994,7 +933,6 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrIpublic DocSet answer; // maybe null. Sometimes we have a docSet answer that represents the complete answer / result.public Filter filter; // maybe nullpublic DelegatingCollector postFilter; // maybe null- public boolean hasDeletedDocs; // true if it's possible that filter may match deleted docs}/**@@ -1120,7 +1058,6 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrIweights.add(createWeight(rewrite(qq), ScoreMode.COMPLETE_NO_SCORES, 1));}pf.filter = new FilterImpl(answer, weights);- pf.hasDeletedDocs = (answer == null); // if all clauses were uncached, the resulting filter may match deleted docs}// Set pf.postFilter