@@ -28,6 +28,8 @@ public class PaginationIT extends SQLIntegTestCase {
2828 public void init () throws IOException {
2929 loadIndex (Index .CALCS );
3030 loadIndex (Index .ONLINE );
31+ loadIndex (Index .DOG );
32+ loadIndex (Index .DOGS2 );
3133 }
3234
3335 @ Test
@@ -251,6 +253,45 @@ public void testAlias() throws Exception {
251253 assertEquals (aliasFilteredResponse .getInt ("size" ), 4 );
252254 }
253255
256+ @ Test
257+ public void testAliasResultConsistency () throws Exception {
258+ String aliasName = "alias_dog_consistency" ;
259+
260+ // Create an alias that maps to both DOG and DOGS2 indices
261+ String createAliasQuery =
262+ String .format (
263+ "{ \" actions\" : [ "
264+ + "{ \" add\" : { \" index\" : \" %s\" , \" alias\" : \" %s\" } }, "
265+ + "{ \" add\" : { \" index\" : \" %s\" , \" alias\" : \" %s\" } } "
266+ + "] }" ,
267+ Index .DOG .getName (), aliasName , Index .DOGS2 .getName (), aliasName );
268+ Request createAliasRequest = new Request ("POST" , "/_aliases" );
269+ createAliasRequest .setJsonEntity (createAliasQuery );
270+ JSONObject aliasResponse = new JSONObject (executeRequest (createAliasRequest ));
271+ assertTrue (aliasResponse .getBoolean ("acknowledged" ));
272+
273+ // Query both indices directly (same indices the alias points to)
274+ String directQuery =
275+ String .format ("SELECT * FROM %s, %s" , Index .DOG .getName (), Index .DOGS2 .getName ());
276+ JSONObject directResponse = new JSONObject (executeFetchQuery (directQuery , 10 , "jdbc" ));
277+
278+ // Query using alias (which points to the same two indices)
279+ String aliasQuery = String .format ("SELECT * FROM %s" , aliasName );
280+ JSONObject aliasQueryResponse = new JSONObject (executeFetchQuery (aliasQuery , 10 , "jdbc" ));
281+
282+ assertEquals (directResponse .getInt ("size" ), aliasQueryResponse .getInt ("size" ));
283+
284+ // Clean up alias
285+ String deleteAliasQuery =
286+ String .format (
287+ "{ \" actions\" : [ { \" remove\" : { \" index\" : \" %s\" , \" alias\" : \" %s\" } }, {"
288+ + " \" remove\" : { \" index\" : \" %s\" , \" alias\" : \" %s\" } } ] }" ,
289+ Index .DOG .getName (), aliasName , Index .DOGS2 .getName (), aliasName );
290+ Request deleteAliasRequest = new Request ("POST" , "/_aliases" );
291+ deleteAliasRequest .setJsonEntity (deleteAliasQuery );
292+ executeRequest (deleteAliasRequest );
293+ }
294+
254295 private String executeFetchQuery (String query , int fetchSize , String requestType , String filter )
255296 throws IOException {
256297 String endpoint = "/_plugins/_sql?format=" + requestType ;
0 commit comments