From 899189694f32edc808fd0e0ce3491587e9ae479e Mon Sep 17 00:00:00 2001 From: Bogdan Dumitrescu Date: Mon, 14 Oct 2013 13:36:16 +0100 Subject: [PATCH] Replaced hardcoded boolean value with correct parameter Implemented changes suggested by review. Closes #3898 --- .../classic/MapperQueryParser.java | 2 +- .../search/query/SimpleQueryTests.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java index b8420187bc9..077d17cb34d 100644 --- a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java +++ b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java @@ -182,7 +182,7 @@ public class MapperQueryParser extends QueryParser { } else { List clauses = new ArrayList(); for (String mField : fields) { - Query q = getFieldQuerySingle(mField, queryText, true); + Query q = getFieldQuerySingle(mField, queryText, quoted); if (q != null) { applyBoost(mField, q); clauses.add(new BooleanClause(q, BooleanClause.Occur.SHOULD)); diff --git a/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java b/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java index ac0039f3089..aa57c69dfc4 100644 --- a/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java +++ b/src/test/java/org/elasticsearch/search/query/SimpleQueryTests.java @@ -1763,4 +1763,35 @@ public class SimpleQueryTests extends AbstractIntegrationTest { searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.queryString("quick brown").defaultField("text").defaultOperator(QueryStringQueryBuilder.Operator.AND)).get(); assertHitCount(searchResponse, 2); } + + @Test // see https://github.com/elasticsearch/elasticsearch/issues/3898 + public void testCustomWordDelimiterQueryString() { + client().admin().indices().prepareCreate("test") + .setSettings("analysis.analyzer.my_analyzer.type", "custom", + "analysis.analyzer.my_analyzer.tokenizer", "whitespace", + "analysis.analyzer.my_analyzer.filter", "custom_word_delimiter", + "analysis.filter.custom_word_delimiter.type", "word_delimiter", + "analysis.filter.custom_word_delimiter.generate_word_parts", "true", + "analysis.filter.custom_word_delimiter.generate_number_parts", "false", + "analysis.filter.custom_word_delimiter.catenate_numbers", "true", + "analysis.filter.custom_word_delimiter.catenate_words", "false", + "analysis.filter.custom_word_delimiter.split_on_case_change", "false", + "analysis.filter.custom_word_delimiter.split_on_numerics", "false", + "analysis.filter.custom_word_delimiter.stem_english_possessive", "false") + .addMapping("type1", "field1", "type=string,analyzer=my_analyzer", "field2", "type=string,analyzer=my_analyzer") + .get(); + + ensureGreen(); + + client().prepareIndex("test", "type1", "1").setSource("field1", "foo bar baz", "field2", "not needed").get(); + refresh(); + + SearchResponse response = client() + .prepareSearch("test") + .setQuery( + QueryBuilders.queryString("foo.baz").useDisMax(false).defaultOperator(QueryStringQueryBuilder.Operator.AND) + .field("field1").field("field2")).get(); + + assertHitCount(response, 1l); + } }