Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fuzziness parsing in multi_match function. Update tests. #668

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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