no need to cache filters again when handling named filters

This commit is contained in:
kimchy 2011-04-22 00:37:20 +03:00
parent 4c295a28d5
commit d8d47abcba
1 changed files with 6 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.ImmutableMap;
import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.lucene.docset.DocSet; import org.elasticsearch.common.lucene.docset.DocSet;
import org.elasticsearch.common.lucene.docset.DocSets;
import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.Uid;
import org.elasticsearch.search.SearchParseElement; import org.elasticsearch.search.SearchParseElement;
import org.elasticsearch.search.fetch.SearchHitPhase; import org.elasticsearch.search.fetch.SearchHitPhase;
@ -54,11 +55,13 @@ public class MatchedFiltersSearchHitPhase implements SearchHitPhase {
for (Map.Entry<String, Filter> entry : context.parsedQuery().namedFilters().entrySet()) { for (Map.Entry<String, Filter> entry : context.parsedQuery().namedFilters().entrySet()) {
String name = entry.getKey(); String name = entry.getKey();
Filter filter = entry.getValue(); Filter filter = entry.getValue();
filter = context.filterCache().cache(filter);
try { try {
DocIdSet docIdSet = filter.getDocIdSet(hitContext.reader()); DocIdSet docIdSet = filter.getDocIdSet(hitContext.reader());
if (docIdSet instanceof DocSet && ((DocSet) docIdSet).get(hitContext.docId())) { if (docIdSet != null) {
matchedFilters.add(name); DocSet docSet = DocSets.convert(hitContext.reader(), docIdSet);
if (docSet.get(hitContext.docId())) {
matchedFilters.add(name);
}
} }
} catch (IOException e) { } catch (IOException e) {
// ignore // ignore