1717import org .elasticsearch .xcontent .XContentType ;
1818import org .elasticsearch .xpack .esql .AssertWarnings ;
1919import org .elasticsearch .xpack .esql .action .EsqlCapabilities ;
20+ import org .hamcrest .Matcher ;
2021import org .junit .After ;
2122import org .junit .Assert ;
2223
@@ -62,7 +63,7 @@ public void testTimestampFilterFromQuery() throws IOException {
6263
6364 // filter includes both indices in the result (all columns, all rows)
6465 RestEsqlTestCase .RequestObjectBuilder builder = timestampFilter ("gte" , "2023-01-01" ).query (from ("test*" ));
65- assertResultMap (
66+ assertQueryResult (
6667 runEsql (builder ),
6768 matchesList ().item (matchesMap ().entry ("name" , "@timestamp" ).entry ("type" , "date" ))
6869 .item (matchesMap ().entry ("name" , "id1" ).entry ("type" , "integer" ))
@@ -73,7 +74,7 @@ public void testTimestampFilterFromQuery() throws IOException {
7374
7475 // filter includes only test1. Columns from test2 are filtered out, as well (not only rows)!
7576 builder = timestampFilter ("gte" , "2024-01-01" ).query (from ("test*" ));
76- assertResultMap (
77+ assertQueryResult (
7778 runEsql (builder ),
7879 matchesList ().item (matchesMap ().entry ("name" , "@timestamp" ).entry ("type" , "date" ))
7980 .item (matchesMap ().entry ("name" , "id1" ).entry ("type" , "integer" ))
@@ -84,7 +85,7 @@ public void testTimestampFilterFromQuery() throws IOException {
8485 // filter excludes both indices (no rows); the first analysis step fails because there are no columns, a second attempt succeeds
8586 // after eliminating the index filter. All columns are returned.
8687 builder = timestampFilter ("gte" , "2025-01-01" ).query (from ("test*" ));
87- assertResultMap (
88+ assertQueryResult (
8889 runEsql (builder ),
8990 matchesList ().item (matchesMap ().entry ("name" , "@timestamp" ).entry ("type" , "date" ))
9091 .item (matchesMap ().entry ("name" , "id1" ).entry ("type" , "integer" ))
@@ -102,7 +103,7 @@ public void testFieldExistsFilter_KeepWildcard() throws IOException {
102103
103104 // filter includes only test1. Columns and rows of test2 are filtered out
104105 RestEsqlTestCase .RequestObjectBuilder builder = existsFilter ("id1" ).query (from ("test*" ));
105- assertResultMap (
106+ assertQueryResult (
106107 runEsql (builder ),
107108 matchesList ().item (matchesMap ().entry ("name" , "@timestamp" ).entry ("type" , "date" ))
108109 .item (matchesMap ().entry ("name" , "id1" ).entry ("type" , "integer" ))
@@ -113,7 +114,7 @@ public void testFieldExistsFilter_KeepWildcard() throws IOException {
113114 // filter includes only test1. Columns from test2 are filtered out, as well (not only rows)!
114115 builder = existsFilter ("id1" ).query (from ("test*" ) + " METADATA _index | KEEP _index, id*" );
115116 Map <String , Object > result = runEsql (builder );
116- assertResultMap (
117+ assertQueryResult (
117118 result ,
118119 matchesList ().item (matchesMap ().entry ("name" , "_index" ).entry ("type" , "keyword" ))
119120 .item (matchesMap ().entry ("name" , "id1" ).entry ("type" , "integer" )),
@@ -138,7 +139,7 @@ public void testFieldExistsFilter_With_ExplicitUseOfDiscardedIndexFields() throw
138139 from ("test*" ) + " METADATA _index | SORT id2 | KEEP _index, id*"
139140 );
140141 Map <String , Object > result = runEsql (builder );
141- assertResultMap (
142+ assertQueryResult (
142143 result ,
143144 matchesList ().item (matchesMap ().entry ("name" , "_index" ).entry ("type" , "keyword" ))
144145 .item (matchesMap ().entry ("name" , "id1" ).entry ("type" , "integer" ))
@@ -298,4 +299,9 @@ protected void indexTimestampDataForClient(RestClient client, int docs, String i
298299 Assert .assertEquals ("{\" errors\" :false}" , EntityUtils .toString (response .getEntity (), StandardCharsets .UTF_8 ));
299300 }
300301 }
302+
303+ protected void assertQueryResult (Map <String , Object > result , Matcher <?> columnMatcher , Matcher <?> valuesMatcher ) {
304+ assertResultMap (result , columnMatcher , valuesMatcher );
305+ }
306+
301307}
0 commit comments