Search: When searching against a type with a dfs search type, dfs is ignored, closes #1546.

This commit is contained in:
Shay Banon 2011-12-16 19:17:31 +02:00
parent f74256afcd
commit cb4c249a65
2 changed files with 22 additions and 12 deletions

View File

@ -127,16 +127,26 @@ public class HighlightPhase implements FetchSubPhase {
// QueryScorer uses WeightedSpanTermExtractor to extract terms, but we can't really plug into
// it, so, we hack here (and really only support top level queries)
Query query = context.parsedQuery().query();
while (true) {
boolean extracted = false;
if (query instanceof FunctionScoreQuery) {
query = ((FunctionScoreQuery) query).getSubQuery();
extracted = true;
} else if (query instanceof FiltersFunctionScoreQuery) {
query = ((FiltersFunctionScoreQuery) query).getSubQuery();
extracted = true;
} else if (query instanceof ConstantScoreQuery) {
ConstantScoreQuery q = (ConstantScoreQuery) query;
if (q.getQuery() != null) {
query = q.getQuery();
extracted = true;
}
}
if (!extracted) {
break;
}
}
QueryScorer queryScorer = new QueryScorer(query, null);
queryScorer.setExpandMultiTermQuery(true);
Fragmenter fragmenter;

View File

@ -81,6 +81,10 @@ public class QueryPhase implements SearchPhase {
if (context.queryBoost() != 1.0f) {
context.parsedQuery(new ParsedQuery(new FunctionScoreQuery(context.query(), new BoostScoreFunction(context.queryBoost())), context.parsedQuery()));
}
Filter searchFilter = context.mapperService().searchFilter(context.types());
if (searchFilter != null) {
context.parsedQuery(new ParsedQuery(new FilteredQuery(context.query(), context.filterCache().cache(searchFilter)), context.parsedQuery()));
}
facetPhase.preProcess(context);
}
@ -165,10 +169,6 @@ public class QueryPhase implements SearchPhase {
searchContext.queryResult().size(searchContext.size());
Query query = searchContext.query();
Filter searchFilter = searchContext.mapperService().searchFilter(searchContext.types());
if (searchFilter != null) {
query = new FilteredQuery(query, searchContext.filterCache().cache(searchFilter));
}
TopDocs topDocs;
int numDocs = searchContext.from() + searchContext.size();