optimize query facet to extract filter from constant_score queries automatically

This commit is contained in:
kimchy 2011-03-02 00:18:26 +02:00
parent 60b423b741
commit 9560451896
1 changed files with 6 additions and 5 deletions

View File

@ -20,10 +20,7 @@
package org.elasticsearch.search.facet.query;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.FilteredQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryWrapperFilter;
import org.apache.lucene.search.*;
import org.elasticsearch.common.lucene.docset.DocSet;
import org.elasticsearch.common.lucene.docset.DocSets;
import org.elasticsearch.common.lucene.search.Queries;
@ -50,7 +47,7 @@ public class QueryFacetCollector extends AbstractFacetCollector {
if (possibleFilter != null) {
this.filter = possibleFilter;
} else {
this.filter = new QueryWrapperFilter(query);
this.filter = filterCache.weakCache(new QueryWrapperFilter(query));
}
}
@ -77,6 +74,10 @@ public class QueryFacetCollector extends AbstractFacetCollector {
if (Queries.isMatchAllQuery(fQuery.getQuery())) {
return fQuery.getFilter();
}
} else if (query instanceof DeletionAwareConstantScoreQuery) {
return ((DeletionAwareConstantScoreQuery) query).getFilter();
} else if (query instanceof ConstantScoreQuery) {
return ((ConstantScoreQuery) query).getFilter();
}
return null;
}