From c711709168db6f719ac9e6acf22e3441a9ff7710 Mon Sep 17 00:00:00 2001
From: Robert Muir
Date: Mon, 18 Oct 2010 02:54:20 +0000
Subject: [PATCH] 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
---
lucene/contrib/CHANGES.txt | 6 +++++-
.../queryParser/standard/MultiFieldQueryParserWrapper.java | 3 +--
.../lucene/queryParser/standard/QueryParserWrapper.java | 4 ++--
.../lucene/queryParser/standard/StandardQueryParser.java | 2 +-
.../queryParser/standard/config/FieldBoostMapAttribute.java | 4 ++--
.../standard/config/FieldBoostMapAttributeImpl.java | 6 +++---
.../lucene/queryParser/standard/TestMultiFieldQPHelper.java | 2 +-
.../standard/TestMultiFieldQueryParserWrapper.java | 2 +-
8 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/lucene/contrib/CHANGES.txt b/lucene/contrib/CHANGES.txt
index cc7674c4497..3f0c67e8461 100644
--- a/lucene/contrib/CHANGES.txt
+++ b/lucene/contrib/CHANGES.txt
@@ -154,7 +154,11 @@ API Changes
* LUCENE-2626: FastVectorHighlighter: enable FragListBuilder and FragmentsBuilder
to be set per-field override. (Koji Sekiguchi)
-
+
+ * LUCENE-2712: FieldBoostMapAttribute in contrib/queryparser was changed from
+ a Map to a Map. Per the CharSequence javadoc,
+ CharSequence is inappropriate as a map key. (Robert Muir)
+
New features
* LUCENE-2306: Add NumericRangeFilter and NumericRangeQuery support to XMLQueryParser.
diff --git a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/MultiFieldQueryParserWrapper.java b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/MultiFieldQueryParserWrapper.java
index 8cb3db59401..46eb864a250 100644
--- a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/MultiFieldQueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/MultiFieldQueryParserWrapper.java
@@ -74,8 +74,7 @@ public class MultiFieldQueryParserWrapper extends QueryParserWrapper {
* what fields they appear.
*
*/
- @SuppressWarnings("unchecked")
-public MultiFieldQueryParserWrapper(String[] fields, Analyzer analyzer, Map boosts) {
+public MultiFieldQueryParserWrapper(String[] fields, Analyzer analyzer, Map boosts) {
this(fields, analyzer);
StandardQueryParser qpHelper = getQueryParserHelper();
diff --git a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java
index 7572d7ade67..839cfa3aae5 100644
--- a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java
@@ -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.parser.StandardSyntaxParser;
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.MultiTermQuery;
import org.apache.lucene.search.Query;
@@ -462,8 +463,7 @@ public class QueryParserWrapper {
throw new UnsupportedOperationException();
}
- @SuppressWarnings("unchecked")
- protected Query getBooleanQuery(List clauses, boolean disableCoord)
+ protected Query getBooleanQuery(List clauses, boolean disableCoord)
throws ParseException {
throw new UnsupportedOperationException();
}
diff --git a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java
index 30229f28863..1cadb1b5216 100644
--- a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java
+++ b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/StandardQueryParser.java
@@ -413,7 +413,7 @@ public class StandardQueryParser extends QueryParserHelper {
attr.setFuzzyMinSimilarity(fuzzyMinSim);
}
- public void setFieldsBoost(Map boosts) {
+ public void setFieldsBoost(Map boosts) {
FieldBoostMapAttribute attr = getQueryConfigHandler().addAttribute(FieldBoostMapAttribute.class);
attr.setFieldBoostMap(boosts);
}
diff --git a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttribute.java b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttribute.java
index ba0a702ee7c..81965be0e88 100644
--- a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttribute.java
+++ b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttribute.java
@@ -30,6 +30,6 @@ public interface FieldBoostMapAttribute extends Attribute {
/**
* @param boosts a mapping from field name to its default boost
*/
- public void setFieldBoostMap(Map boosts);
- public Map getFieldBoostMap();
+ public void setFieldBoostMap(Map boosts);
+ public Map getFieldBoostMap();
}
diff --git a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttributeImpl.java b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttributeImpl.java
index 853b4ce5098..debcc563450 100644
--- a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttributeImpl.java
+++ b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/config/FieldBoostMapAttributeImpl.java
@@ -38,18 +38,18 @@ public class FieldBoostMapAttributeImpl extends AttributeImpl
private static final long serialVersionUID = -2104763012523049527L;
- private Map boosts = new LinkedHashMap();
+ private Map boosts = new LinkedHashMap();
public FieldBoostMapAttributeImpl() {
// empty constructor
}
- public void setFieldBoostMap(Map boosts) {
+ public void setFieldBoostMap(Map boosts) {
this.boosts = boosts;
}
- public Map getFieldBoostMap() {
+ public Map getFieldBoostMap() {
return this.boosts;
}
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
index f74727a5a1c..9eb4c2c060c 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
@@ -143,7 +143,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
}
public void testBoostsSimple() throws Exception {
- Map boosts = new HashMap();
+ Map boosts = new HashMap();
boosts.put("b", Float.valueOf(5));
boosts.put("t", Float.valueOf(10));
String[] fields = { "b", "t" };
diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
index 3d0ae089d5f..5a048828cba 100644
--- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
+++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
@@ -144,7 +144,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
}
public void testBoostsSimple() throws Exception {
- Map boosts = new HashMap();
+ Map boosts = new HashMap();
boosts.put("b", Float.valueOf(5));
boosts.put("t", Float.valueOf(10));
String[] fields = { "b", "t" };