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:
Mark Robert Miller 2008-09-09 10:52:50 +00:00
parent d5a40278bc
commit 5147f0563f
3 changed files with 9 additions and 8 deletions

View File

@ -25,7 +25,7 @@ public class SpanScorer implements Scorer {
private float maxTermWeight;
private int position = -1;
private String defaultField;
private boolean highlightCnstScrRngQuery;
private static boolean highlightCnstScrRngQuery;
/**
* @param query
@ -184,7 +184,7 @@ public class SpanScorer implements Scorer {
/**
* @return whether ConstantScoreRangeQuerys are set to be highlighted
*/
public boolean isHighlightCnstScrRngQuery() {
public static boolean isHighlightCnstScrRngQuery() {
return highlightCnstScrRngQuery;
}
@ -198,12 +198,12 @@ public class SpanScorer implements Scorer {
/**
* 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
*/
public void setHighlightCnstScrRngQuery(boolean highlightCnstScrRngQuery) {
this.highlightCnstScrRngQuery = highlightCnstScrRngQuery;
public static void setHighlightCnstScrRngQuery(boolean highlight) {
highlightCnstScrRngQuery = highlight;
}
/*

View File

@ -179,7 +179,7 @@ public class WeightedSpanTermExtractor {
sp.setBoost(query.getBoost());
extractWeightedSpanTerms(terms, sp);
}
} else if (query instanceof ConstantScoreRangeQuery) {
} else if (highlightCnstScrRngQuery && query instanceof ConstantScoreRangeQuery) {
ConstantScoreRangeQuery q = (ConstantScoreRangeQuery) query;
Term lower = new Term(fieldName, q.getLowerVal());
Term upper = new Term(fieldName, q.getUpperVal());

View File

@ -488,8 +488,9 @@ public class HighlighterTest extends TestCase implements Formatter {
tokenStream = new CachingTokenFilter(analyzer.tokenStream(HighlighterTest.FIELD_NAME,
new StringReader(text)));
SpanScorer.setHighlightCnstScrRngQuery(true);
scorer = new SpanScorer(query, HighlighterTest.FIELD_NAME, (CachingTokenFilter) tokenStream);
scorer.setHighlightCnstScrRngQuery(true);
Highlighter highlighter = new Highlighter(this, scorer);