LUCENE-7376: Add support for ToParentBlockJoinQuery to fast vector highlighter's FieldQuery.

This commit is contained in:
Martijn van Groningen 2016-07-14 10:06:15 +02:00
parent 51d4af6859
commit 3a71c7d8df
3 changed files with 24 additions and 0 deletions

View File

@ -109,6 +109,9 @@ Improvements
chain that is about normalization for range/fuzzy/wildcard queries.
(Adrien Grand)
* LUCENE-7376: Add support for ToParentBlockJoinQuery to fast vector highlighter's
FieldQuery. (Martijn van Groningen)
Optimizations
* LUCENE-7330, LUCENE-7339: Speed up conjunction queries. (Adrien Grand)

View File

@ -37,6 +37,7 @@ import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
import org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo;
/**
@ -137,6 +138,11 @@ public class FieldQuery {
if (q != null) {
flatten( q, reader, flatQueries, boost);
}
} else if (sourceQuery instanceof ToParentBlockJoinQuery) {
Query childQuery = ((ToParentBlockJoinQuery) sourceQuery).getChildQuery();
if (childQuery != null) {
flatten(childQuery, reader, flatQueries, boost);
}
} else if (reader != null) {
Query query = sourceQuery;
Query rewritten;

View File

@ -27,12 +27,16 @@ import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BoostQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.search.join.QueryBitSetProducer;
import org.apache.lucene.search.join.ScoreMode;
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
import org.apache.lucene.search.vectorhighlight.FieldQuery.QueryPhraseMap;
import org.apache.lucene.search.vectorhighlight.FieldTermStack.TermInfo;
import org.apache.lucene.util.BytesRef;
@ -951,4 +955,15 @@ public class FieldQueryTest extends AbstractTestCase {
assertCollectionQueries( flatQueries, tq( boost, "A" ) );
}
public void testFlattenToParentBlockJoinQuery() throws Exception {
initBoost();
Query childQuery = tq(boost, "a");
Query query = new ToParentBlockJoinQuery(childQuery, new QueryBitSetProducer(new MatchAllDocsQuery()), ScoreMode.None);
query = new BoostQuery(query, boost );
FieldQuery fq = new FieldQuery(query, true, true );
Set<Query> flatQueries = new HashSet<>();
fq.flatten(query, reader, flatQueries, 1f );
assertCollectionQueries(flatQueries, tq(boost, "a"));
}
}