mirror of https://github.com/apache/lucene.git
LUCENE-1357: SpanScorer does not respect ConstantScoreRangeQuery setting
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@693432 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d5a40278bc
commit
5147f0563f
|
@ -25,7 +25,7 @@ public class SpanScorer implements Scorer {
|
||||||
private float maxTermWeight;
|
private float maxTermWeight;
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
private String defaultField;
|
private String defaultField;
|
||||||
private boolean highlightCnstScrRngQuery;
|
private static boolean highlightCnstScrRngQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param query
|
* @param query
|
||||||
|
@ -184,7 +184,7 @@ public class SpanScorer implements Scorer {
|
||||||
/**
|
/**
|
||||||
* @return whether ConstantScoreRangeQuerys are set to be highlighted
|
* @return whether ConstantScoreRangeQuerys are set to be highlighted
|
||||||
*/
|
*/
|
||||||
public boolean isHighlightCnstScrRngQuery() {
|
public static boolean isHighlightCnstScrRngQuery() {
|
||||||
return highlightCnstScrRngQuery;
|
return highlightCnstScrRngQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,12 +198,12 @@ public class SpanScorer implements Scorer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns highlighting of ConstantScoreRangeQuery on/off. ConstantScoreRangeQuerys cannot be
|
* Turns highlighting of ConstantScoreRangeQuery on/off. ConstantScoreRangeQuerys cannot be
|
||||||
* highlighted if you rewrite the query first.
|
* highlighted if you rewrite the query first. Must be called before SpanScorer construction.
|
||||||
*
|
*
|
||||||
* @param highlightCnstScrRngQuery
|
* @param highlightCnstScrRngQuery
|
||||||
*/
|
*/
|
||||||
public void setHighlightCnstScrRngQuery(boolean highlightCnstScrRngQuery) {
|
public static void setHighlightCnstScrRngQuery(boolean highlight) {
|
||||||
this.highlightCnstScrRngQuery = highlightCnstScrRngQuery;
|
highlightCnstScrRngQuery = highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class WeightedSpanTermExtractor {
|
||||||
sp.setBoost(query.getBoost());
|
sp.setBoost(query.getBoost());
|
||||||
extractWeightedSpanTerms(terms, sp);
|
extractWeightedSpanTerms(terms, sp);
|
||||||
}
|
}
|
||||||
} else if (query instanceof ConstantScoreRangeQuery) {
|
} else if (highlightCnstScrRngQuery && query instanceof ConstantScoreRangeQuery) {
|
||||||
ConstantScoreRangeQuery q = (ConstantScoreRangeQuery) query;
|
ConstantScoreRangeQuery q = (ConstantScoreRangeQuery) query;
|
||||||
Term lower = new Term(fieldName, q.getLowerVal());
|
Term lower = new Term(fieldName, q.getLowerVal());
|
||||||
Term upper = new Term(fieldName, q.getUpperVal());
|
Term upper = new Term(fieldName, q.getUpperVal());
|
||||||
|
|
|
@ -488,8 +488,9 @@ public class HighlighterTest extends TestCase implements Formatter {
|
||||||
|
|
||||||
tokenStream = new CachingTokenFilter(analyzer.tokenStream(HighlighterTest.FIELD_NAME,
|
tokenStream = new CachingTokenFilter(analyzer.tokenStream(HighlighterTest.FIELD_NAME,
|
||||||
new StringReader(text)));
|
new StringReader(text)));
|
||||||
|
|
||||||
|
SpanScorer.setHighlightCnstScrRngQuery(true);
|
||||||
scorer = new SpanScorer(query, HighlighterTest.FIELD_NAME, (CachingTokenFilter) tokenStream);
|
scorer = new SpanScorer(query, HighlighterTest.FIELD_NAME, (CachingTokenFilter) tokenStream);
|
||||||
scorer.setHighlightCnstScrRngQuery(true);
|
|
||||||
|
|
||||||
Highlighter highlighter = new Highlighter(this, scorer);
|
Highlighter highlighter = new Highlighter(this, scorer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue