LUCENE-2712: Fix FieldBoostMapAttribute to not use CharSequence as a map key

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1023637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-10-18 02:54:20 +00:00
parent 37fda0b1c1
commit c711709168
8 changed files with 16 additions and 13 deletions

View File

@ -155,6 +155,10 @@ API Changes
* LUCENE-2626: FastVectorHighlighter: enable FragListBuilder and FragmentsBuilder * LUCENE-2626: FastVectorHighlighter: enable FragListBuilder and FragmentsBuilder
to be set per-field override. (Koji Sekiguchi) to be set per-field override. (Koji Sekiguchi)
* LUCENE-2712: FieldBoostMapAttribute in contrib/queryparser was changed from
a Map<CharSequence,Float> to a Map<String,Float>. Per the CharSequence javadoc,
CharSequence is inappropriate as a map key. (Robert Muir)
New features New features
* LUCENE-2306: Add NumericRangeFilter and NumericRangeQuery support to XMLQueryParser. * LUCENE-2306: Add NumericRangeFilter and NumericRangeQuery support to XMLQueryParser.

View File

@ -74,8 +74,7 @@ public class MultiFieldQueryParserWrapper extends QueryParserWrapper {
* what fields they appear. * what fields they appear.
* </p> * </p>
*/ */
@SuppressWarnings("unchecked") public MultiFieldQueryParserWrapper(String[] fields, Analyzer analyzer, Map<String, Float> boosts) {
public MultiFieldQueryParserWrapper(String[] fields, Analyzer analyzer, Map boosts) {
this(fields, analyzer); this(fields, analyzer);
StandardQueryParser qpHelper = getQueryParserHelper(); StandardQueryParser qpHelper = getQueryParserHelper();

View File

@ -49,6 +49,7 @@ import org.apache.lucene.queryParser.standard.config.RangeCollatorAttribute;
import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler; import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
import org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser; import org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser;
import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline; import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
@ -462,8 +463,7 @@ public class QueryParserWrapper {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@SuppressWarnings("unchecked") protected Query getBooleanQuery(List<BooleanClause> clauses, boolean disableCoord)
protected Query getBooleanQuery(List clauses, boolean disableCoord)
throws ParseException { throws ParseException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -413,7 +413,7 @@ public class StandardQueryParser extends QueryParserHelper {
attr.setFuzzyMinSimilarity(fuzzyMinSim); attr.setFuzzyMinSimilarity(fuzzyMinSim);
} }
public void setFieldsBoost(Map<CharSequence, Float> boosts) { public void setFieldsBoost(Map<String, Float> boosts) {
FieldBoostMapAttribute attr = getQueryConfigHandler().addAttribute(FieldBoostMapAttribute.class); FieldBoostMapAttribute attr = getQueryConfigHandler().addAttribute(FieldBoostMapAttribute.class);
attr.setFieldBoostMap(boosts); attr.setFieldBoostMap(boosts);
} }

View File

@ -30,6 +30,6 @@ public interface FieldBoostMapAttribute extends Attribute {
/** /**
* @param boosts a mapping from field name to its default boost * @param boosts a mapping from field name to its default boost
*/ */
public void setFieldBoostMap(Map<CharSequence, Float> boosts); public void setFieldBoostMap(Map<String, Float> boosts);
public Map<CharSequence, Float> getFieldBoostMap(); public Map<String, Float> getFieldBoostMap();
} }

View File

@ -38,18 +38,18 @@ public class FieldBoostMapAttributeImpl extends AttributeImpl
private static final long serialVersionUID = -2104763012523049527L; private static final long serialVersionUID = -2104763012523049527L;
private Map<CharSequence, Float> boosts = new LinkedHashMap<CharSequence, Float>(); private Map<String, Float> boosts = new LinkedHashMap<String, Float>();
public FieldBoostMapAttributeImpl() { public FieldBoostMapAttributeImpl() {
// empty constructor // empty constructor
} }
public void setFieldBoostMap(Map<CharSequence, Float> boosts) { public void setFieldBoostMap(Map<String, Float> boosts) {
this.boosts = boosts; this.boosts = boosts;
} }
public Map<CharSequence, Float> getFieldBoostMap() { public Map<String, Float> getFieldBoostMap() {
return this.boosts; return this.boosts;
} }

View File

@ -143,7 +143,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
} }
public void testBoostsSimple() throws Exception { public void testBoostsSimple() throws Exception {
Map<CharSequence,Float> boosts = new HashMap<CharSequence,Float>(); Map<String,Float> boosts = new HashMap<String,Float>();
boosts.put("b", Float.valueOf(5)); boosts.put("b", Float.valueOf(5));
boosts.put("t", Float.valueOf(10)); boosts.put("t", Float.valueOf(10));
String[] fields = { "b", "t" }; String[] fields = { "b", "t" };

View File

@ -144,7 +144,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
} }
public void testBoostsSimple() throws Exception { public void testBoostsSimple() throws Exception {
Map<CharSequence,Float> boosts = new HashMap<CharSequence,Float>(); Map<String,Float> boosts = new HashMap<String,Float>();
boosts.put("b", Float.valueOf(5)); boosts.put("b", Float.valueOf(5));
boosts.put("t", Float.valueOf(10)); boosts.put("t", Float.valueOf(10));
String[] fields = { "b", "t" }; String[] fields = { "b", "t" };