mirror of https://github.com/apache/lucene.git
SOLR-9027: Collect the TermContexts in createWeight
This commit is contained in:
parent
86f371cbc6
commit
3cc4125a8a
|
@ -100,8 +100,6 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
|
||||||
private class GraphTermsQuery extends Query implements ExtendedQuery {
|
private class GraphTermsQuery extends Query implements ExtendedQuery {
|
||||||
|
|
||||||
private Term[] queryTerms;
|
private Term[] queryTerms;
|
||||||
private List<TermContext> finalContexts;
|
|
||||||
private List<Term> finalTerms;
|
|
||||||
private String field;
|
private String field;
|
||||||
private int maxDocFreq;
|
private int maxDocFreq;
|
||||||
private Object id;
|
private Object id;
|
||||||
|
@ -147,19 +145,6 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query rewrite(IndexReader reader) throws IOException {
|
public Query rewrite(IndexReader reader) throws IOException {
|
||||||
this.finalContexts = new ArrayList();
|
|
||||||
this.finalTerms = new ArrayList();
|
|
||||||
List<LeafReaderContext> contexts = reader.leaves();
|
|
||||||
TermContext[] termContexts = new TermContext[this.queryTerms.length];
|
|
||||||
collectTermContext(reader, contexts, termContexts, this.queryTerms);
|
|
||||||
for(int i=0; i<termContexts.length; i++) {
|
|
||||||
TermContext termContext = termContexts[i];
|
|
||||||
if(termContext != null && termContext.docFreq() <= this.maxDocFreq) {
|
|
||||||
this.finalContexts.add(termContext);
|
|
||||||
this.finalTerms.add(queryTerms[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +196,20 @@ public class GraphTermsQParserPlugin extends QParserPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
|
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
|
||||||
|
|
||||||
|
List<TermContext> finalContexts = new ArrayList();
|
||||||
|
List<Term> finalTerms = new ArrayList();
|
||||||
|
List<LeafReaderContext> contexts = searcher.getTopReaderContext().leaves();
|
||||||
|
TermContext[] termContexts = new TermContext[this.queryTerms.length];
|
||||||
|
collectTermContext(searcher.getIndexReader(), contexts, termContexts, this.queryTerms);
|
||||||
|
for(int i=0; i<termContexts.length; i++) {
|
||||||
|
TermContext termContext = termContexts[i];
|
||||||
|
if(termContext != null && termContext.docFreq() <= this.maxDocFreq) {
|
||||||
|
finalContexts.add(termContext);
|
||||||
|
finalTerms.add(queryTerms[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new ConstantScoreWeight(this) {
|
return new ConstantScoreWeight(this) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue