Skip to content

Commit

Permalink
Fix encoding for OpenSearch count pushdown
Browse files Browse the repository at this point in the history
  • Loading branch information
bvolpato authored and hashhar committed Sep 19, 2024
1 parent 52821d2 commit 3c1b11c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public long count(String index, int shard, QueryBuilder query)
"GET",
format("/%s/_count?preference=_shards:%s", index, shard),
ImmutableMap.of(),
new StringEntity(sourceBuilder.toString()),
new StringEntity(sourceBuilder.toString(), UTF_8),
new BasicHeader("Content-Type", "application/json"));
}
catch (ResponseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,38 @@ public void testFilters()
assertQuery("SELECT count(*) FROM filter_pushdown WHERE ipv6_column = IPADDRESS '2001:db8::1:0:0:1'", "VALUES 1");
}

@Test
public void testFiltersCharset()
throws IOException
{
String indexName = "filter_charset_pushdown";

@Language("JSON")
String mappings = """
{
"properties": {
"keyword_column": { "type": "keyword" },
"text_column": { "type": "text" }
}
}
""";

createIndex(indexName, mappings);

index(indexName, ImmutableMap.<String, Object>builder()
.put("keyword_column", "Türkiye")
.put("text_column", "Türkiye")
.buildOrThrow());

assertQuery("SELECT count(*) FROM filter_charset_pushdown WHERE keyword_column = 'Türkiye'", "VALUES 1");
assertQuery("SELECT count(*) FROM filter_charset_pushdown WHERE keyword_column = 'bar'", "VALUES 0");
assertQuery("SELECT count(*) FROM filter_charset_pushdown WHERE text_column = 'Türkiye'", "VALUES 1");
assertQuery("SELECT count(*) FROM filter_charset_pushdown WHERE text_column = 'some'", "VALUES 0");

assertQuery("SELECT keyword_column FROM filter_charset_pushdown WHERE keyword_column = 'Türkiye'", "VALUES ('Türkiye')");
assertQuery("SELECT text_column FROM filter_charset_pushdown WHERE text_column = 'Türkiye'", "VALUES ('Türkiye')");
}

@Test
public void testLimitPushdown()
throws IOException
Expand Down

0 comments on commit 3c1b11c

Please sign in to comment.