mirror of https://github.com/apache/lucene.git
LUCENE-7187: Block join queries' Weight#extractTerms(...) implementations should delegate to the wrapped weight.
This commit is contained in:
parent
dd8c199c0b
commit
d7867b80f8
|
@ -73,6 +73,9 @@ Bug Fixes
|
||||||
* LUCENE-7168: Switch to stable encode for geo3d, remove quantization
|
* LUCENE-7168: Switch to stable encode for geo3d, remove quantization
|
||||||
test leniency, remove dead code (Mike McCandless)
|
test leniency, remove dead code (Mike McCandless)
|
||||||
|
|
||||||
|
* LUCENE-7187: Block join queries' Weight#extractTerms(...) implementations
|
||||||
|
should delegate to the wrapped weight. (Martijn van Groningen)
|
||||||
|
|
||||||
Other
|
Other
|
||||||
|
|
||||||
* LUCENE-7174: Upgrade randomizedtesting to 2.3.4. (Uwe Schindler, Dawid Weiss)
|
* LUCENE-7174: Upgrade randomizedtesting to 2.3.4. (Uwe Schindler, Dawid Weiss)
|
||||||
|
|
|
@ -103,7 +103,9 @@ public class ToChildBlockJoinQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extractTerms(Set<Term> terms) {}
|
public void extractTerms(Set<Term> terms) {
|
||||||
|
parentWeight.extractTerms(terms);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getValueForNormalization() throws IOException {
|
public float getValueForNormalization() throws IOException {
|
||||||
|
|
|
@ -125,21 +125,21 @@ public class ToParentBlockJoinQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BlockJoinWeight extends Weight {
|
private static class BlockJoinWeight extends Weight {
|
||||||
private final Query joinQuery;
|
|
||||||
private final Weight childWeight;
|
private final Weight childWeight;
|
||||||
private final BitSetProducer parentsFilter;
|
private final BitSetProducer parentsFilter;
|
||||||
private final ScoreMode scoreMode;
|
private final ScoreMode scoreMode;
|
||||||
|
|
||||||
public BlockJoinWeight(Query joinQuery, Weight childWeight, BitSetProducer parentsFilter, ScoreMode scoreMode) {
|
public BlockJoinWeight(Query joinQuery, Weight childWeight, BitSetProducer parentsFilter, ScoreMode scoreMode) {
|
||||||
super(joinQuery);
|
super(joinQuery);
|
||||||
this.joinQuery = joinQuery;
|
|
||||||
this.childWeight = childWeight;
|
this.childWeight = childWeight;
|
||||||
this.parentsFilter = parentsFilter;
|
this.parentsFilter = parentsFilter;
|
||||||
this.scoreMode = scoreMode;
|
this.scoreMode = scoreMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extractTerms(Set<Term> terms) {}
|
public void extractTerms(Set<Term> terms) {
|
||||||
|
childWeight.extractTerms(terms);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getValueForNormalization() throws IOException {
|
public float getValueForNormalization() throws IOException {
|
||||||
|
|
|
@ -20,8 +20,10 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
|
@ -101,7 +103,35 @@ public class TestBlockJoin extends LuceneTestCase {
|
||||||
job.add(new IntPoint("year", year));
|
job.add(new IntPoint("year", year));
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testExtractTerms() throws Exception {
|
||||||
|
TermQuery termQuery = new TermQuery(new Term("field", "value"));
|
||||||
|
QueryBitSetProducer bitSetProducer = new QueryBitSetProducer(new MatchNoDocsQuery());
|
||||||
|
ToParentBlockJoinQuery toParentBlockJoinQuery = new ToParentBlockJoinQuery(termQuery, bitSetProducer, ScoreMode.None);
|
||||||
|
ToChildBlockJoinQuery toChildBlockJoinQuery = new ToChildBlockJoinQuery(toParentBlockJoinQuery, bitSetProducer);
|
||||||
|
|
||||||
|
Directory directory = newDirectory();
|
||||||
|
final IndexWriter w = new IndexWriter(directory, new IndexWriterConfig(new MockAnalyzer(random())));
|
||||||
|
w.close();
|
||||||
|
IndexReader indexReader = DirectoryReader.open(directory);
|
||||||
|
IndexSearcher indexSearcher = new IndexSearcher(indexReader);
|
||||||
|
|
||||||
|
Weight weight = toParentBlockJoinQuery.createWeight(indexSearcher, false);
|
||||||
|
Set<Term> terms = new HashSet<>();
|
||||||
|
weight.extractTerms(terms);
|
||||||
|
Term[] termArr =terms.toArray(new Term[0]);
|
||||||
|
assertEquals(1, termArr.length);
|
||||||
|
|
||||||
|
weight = toChildBlockJoinQuery.createWeight(indexSearcher, false);
|
||||||
|
terms = new HashSet<>();
|
||||||
|
weight.extractTerms(terms);
|
||||||
|
termArr =terms.toArray(new Term[0]);
|
||||||
|
assertEquals(1, termArr.length);
|
||||||
|
|
||||||
|
indexReader.close();
|
||||||
|
directory.close();
|
||||||
|
}
|
||||||
|
|
||||||
public void testEmptyChildFilter() throws Exception {
|
public void testEmptyChildFilter() throws Exception {
|
||||||
final Directory dir = newDirectory();
|
final Directory dir = newDirectory();
|
||||||
final IndexWriterConfig config = new IndexWriterConfig(new MockAnalyzer(random()));
|
final IndexWriterConfig config = new IndexWriterConfig(new MockAnalyzer(random()));
|
||||||
|
|
Loading…
Reference in New Issue