|
6 | 6 | package org.opensearch.sql.sql; |
7 | 7 |
|
8 | 8 | import static org.opensearch.sql.legacy.TestUtils.getResponseBody; |
9 | | -import static org.opensearch.sql.legacy.TestsConstants.*; |
| 9 | +import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_CALCS; |
| 10 | +import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ONLINE; |
10 | 11 |
|
11 | 12 | import java.io.IOException; |
12 | 13 | import lombok.SneakyThrows; |
@@ -256,22 +257,24 @@ public void testAlias() throws Exception { |
256 | 257 | public void testAliasResultConsistency() throws Exception { |
257 | 258 | String aliasName = "alias_dog_consistency"; |
258 | 259 |
|
259 | | - // Create an alias for 2 index(dog1, dog2) |
| 260 | + // Create an alias that maps to both DOG and DOGS2 indices |
260 | 261 | String createAliasQuery = |
261 | 262 | String.format( |
262 | | - "{ \"actions\": [ { \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } }, " |
263 | | - + "{\"add\": { \"index\": \"%s\", \"alias\": \"%s\" } } ] }", |
| 263 | + "{ \"actions\": [ " |
| 264 | + + "{ \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } }, " |
| 265 | + + "{ \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } } " |
| 266 | + + "] }", |
264 | 267 | Index.DOG.getName(), aliasName, Index.DOGS2.getName(), aliasName); |
265 | 268 | Request createAliasRequest = new Request("POST", "/_aliases"); |
266 | 269 | createAliasRequest.setJsonEntity(createAliasQuery); |
267 | 270 | JSONObject aliasResponse = new JSONObject(executeRequest(createAliasRequest)); |
268 | 271 | assertTrue(aliasResponse.getBoolean("acknowledged")); |
269 | 272 |
|
270 | | - // Query using direct index |
271 | | - String directQuery = String.format("SELECT * FROM %s", TEST_INDEX_DOG); |
| 273 | + // Query both indices directly (same indices the alias points to) |
| 274 | + String directQuery = String.format("SELECT * FROM %s, %s", Index.DOG.getName(), Index.DOGS2.getName()); |
272 | 275 | JSONObject directResponse = new JSONObject(executeFetchQuery(directQuery, 10, "jdbc")); |
273 | 276 |
|
274 | | - // Query using alias |
| 277 | + // Query using alias (which points to the same two indices) |
275 | 278 | String aliasQuery = String.format("SELECT * FROM %s", aliasName); |
276 | 279 | JSONObject aliasQueryResponse = new JSONObject(executeFetchQuery(aliasQuery, 10, "jdbc")); |
277 | 280 |
|
|
0 commit comments