From 5432f9de62a511637cbb9583350a8e8a747b8755 Mon Sep 17 00:00:00 2001 From: Adriano Crestani Campos Date: Wed, 27 Apr 2011 02:49:17 +0000 Subject: [PATCH] LUCENE-3045: QueryNodeImpl.containsTag(String) should lowercase the tag key git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1096983 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/contrib/CHANGES.txt | 8 ++++++++ .../lucene/queryParser/core/nodes/QueryNodeImpl.java | 2 +- .../lucene/queryParser/core/nodes/TestQueryNode.java | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lucene/contrib/CHANGES.txt b/lucene/contrib/CHANGES.txt index 2fa5c4fb996..46a60c87712 100644 --- a/lucene/contrib/CHANGES.txt +++ b/lucene/contrib/CHANGES.txt @@ -42,11 +42,19 @@ API Changes Instead, use SimilarityProvider to return different SweetSpotSimilaritys for different fields, this way all parameters (such as TF factors) can be customized on a per-field basis. (Robert Muir) + +Bug Fixes + + * LUCENE-3045: fixed QueryNodeImpl.containsTag(String key) that was + not lowercasing the key before checking for the tag (Adriano Crestani) ======================= Lucene 3.x (not yet released) ======================= Bug Fixes + * LUCENE-3045: fixed QueryNodeImpl.containsTag(String key) that was + not lowercasing the key before checking for the tag (Adriano Crestani) + * LUCENE-3026: SmartChineseAnalyzer's WordTokenFilter threw NullPointerException on sentences longer than 32,767 characters. (wangzhenghang via Robert Muir) diff --git a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java index 745d8f1529c..dcc4811febc 100644 --- a/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java +++ b/lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/core/nodes/QueryNodeImpl.java @@ -160,7 +160,7 @@ public abstract class QueryNodeImpl implements QueryNode, Cloneable { /** verify if a node contains a tag */ public boolean containsTag(String tagName) { - return this.tags.containsKey(tagName); + return this.tags.containsKey(tagName.toLowerCase()); } public Object getTag(String tagName) { diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/nodes/TestQueryNode.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/nodes/TestQueryNode.java index 23d4fb4ef4c..b805a438ce1 100644 --- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/nodes/TestQueryNode.java +++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/core/nodes/TestQueryNode.java @@ -32,4 +32,16 @@ public class TestQueryNode extends LuceneTestCase { bq.add(Arrays.asList(nodeB)); assertEquals(2, bq.getChildren().size()); } + + /* LUCENE-3045 bug in QueryNodeImpl.containsTag(String key)*/ + public void testTags() throws Exception { + QueryNode node = new FieldQueryNode("foo", "A", 0, 1); + + node.setTag("TaG", new Object()); + assertTrue(node.getTagMap().size() > 0); + assertTrue(node.containsTag("tAg")); + assertTrue(node.getTag("tAg") != null); + + } + }