Skip to content

Commit

Permalink
Fix fuzziness parsing in multi_match function. Update tests. (#668)…
Browse files Browse the repository at this point in the history
… (#669)

Signed-off-by: Yury Fridlyand <[email protected]>
(cherry picked from commit a91c194)

Co-authored-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
1 parent 5f00b9f commit 864732a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public void test_multi_match_all_params() throws IOException {
String query = "SOURCE=" + TEST_INDEX_BEER
+ " | WHERE multi_match(['Body', Tags], 'taste beer', operator='and', analyzer=english,"
+ "auto_generate_synonyms_phrase_query=true, boost = 0.77, cutoff_frequency=0.33,"
+ "fuzziness = 14, fuzzy_transpositions = false, lenient = true, max_expansions = 25,"
+ "fuzziness = 'AUTO:1,5', fuzzy_transpositions = false, lenient = true, max_expansions = 25,"
+ "minimum_should_match = '2<-25% 9<-3', prefix_length = 7, tie_breaker = 0.3,"
+ "type = most_fields, slop = 2, zero_terms_query = 'ALL') | fields Id";
var result = executeQuery(query);
assertEquals(507, result.getInt("total"));
assertEquals(424, result.getInt("total"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public void test_all_params() throws IOException {
String query = "SELECT Id FROM " + TEST_INDEX_BEER
+ " WHERE multi_match(['Body', Tags], 'taste beer', operator='and', analyzer=english,"
+ "auto_generate_synonyms_phrase_query=true, boost = 0.77, cutoff_frequency=0.33,"
+ "fuzziness = 14, fuzzy_transpositions = false, lenient = true, max_expansions = 25,"
+ "fuzziness = 'AUTO:1,5', fuzzy_transpositions = false, lenient = true, max_expansions = 25,"
+ "minimum_should_match = '2<-25% 9<-3', prefix_length = 7, tie_breaker = 0.3,"
+ "type = most_fields, slop = 2, zero_terms_query = 'ALL');";
var result = new JSONObject(executeQuery(query, "jdbc"));
assertEquals(507, result.getInt("total"));
assertEquals(424, result.getInt("total"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public MultiMatchQuery() {
b.autoGenerateSynonymsPhraseQuery(Boolean.parseBoolean(v.stringValue())))
.put("boost", (b, v) -> b.boost(Float.parseFloat(v.stringValue())))
.put("cutoff_frequency", (b, v) -> b.cutoffFrequency(Float.parseFloat(v.stringValue())))
.put("fuzziness", (b, v) -> b.fuzziness(Integer.parseInt(v.stringValue())))
.put("fuzziness", (b, v) -> b.fuzziness(v.stringValue()))
.put("fuzzy_transpositions", (b, v) ->
b.fuzzyTranspositions(Boolean.parseBoolean(v.stringValue())))
.put("lenient", (b, v) -> b.lenient(Boolean.parseBoolean(v.stringValue())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void should_build_multi_match_query_with_custom_parameters() {
+ " \"operator\" : \"AND\",\n"
+ " \"analyzer\" : \"keyword\",\n"
+ " \"slop\" : 1,\n"
+ " \"fuzziness\" : \"2\",\n"
+ " \"fuzziness\" : \"AUTO:2,4\",\n"
+ " \"prefix_length\" : 1,\n"
+ " \"max_expansions\" : 3,\n"
+ " \"minimum_should_match\" : \"3\",\n"
Expand All @@ -527,7 +527,7 @@ void should_build_multi_match_query_with_custom_parameters() {
dsl.namedArgument("analyzer", literal("keyword")),
dsl.namedArgument("auto_generate_synonyms_phrase_query", literal("false")),
dsl.namedArgument("cutoff_frequency", literal("4.3")),
dsl.namedArgument("fuzziness", literal("2")),
dsl.namedArgument("fuzziness", literal("AUTO:2,4")),
dsl.namedArgument("fuzzy_transpositions", literal("false")),
dsl.namedArgument("lenient", literal("false")),
dsl.namedArgument("max_expansions", literal("3")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static Stream<List<Expression>> generateValidData() {
List.of(
dsl.namedArgument("fields", fields_value),
dsl.namedArgument("query", query_value),
dsl.namedArgument("fuzziness", DSL.literal("4"))
dsl.namedArgument("fuzziness", DSL.literal("AUTO:2,4"))
),
List.of(
dsl.namedArgument("fields", fields_value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void can_parse_multi_match_relevance_function() {
assertNotNull(parser.parse(
"SELECT id FROM test WHERE"
+ " multi_match([\"Tags\" ^ 1.5, Title, `Body` 4.2], 'query', analyzer=keyword,"
+ "operator='AND', tie_breaker=0.3, type = \"most_fields\", fuzziness = 4)"));
+ "operator='AND', tie_breaker=0.3, type = \"most_fields\", fuzziness = \"AUTO\")"));
}

@Test
Expand Down

0 comments on commit 864732a

Please sign in to comment.