forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Yury Fridlyand <[email protected]>
- Loading branch information
Showing
19 changed files
with
718 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
integ-test/src/test/java/org/opensearch/sql/sql/SimpleQueryStringIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.sql; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BEER; | ||
|
||
import java.io.IOException; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
|
||
public class SimpleQueryStringIT extends SQLIntegTestCase { | ||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.BEER); | ||
} | ||
|
||
/* | ||
The 'beer.stackexchange' index is a dump of beer.stackexchange.com converted to the format which might be ingested by OpenSearch. | ||
This is a forum like StackOverflow with questions about beer brewing. The dump contains both questions, answers and comments. | ||
The reference query is: | ||
select count(Id) from beer.stackexchange where simple_query_string(["Tags" ^ 1.5, Title, `Body` 4.2], 'taste') and Tags like '% % %' and Title like '%'; | ||
It filters out empty `Tags` and `Title`. | ||
*/ | ||
|
||
@Test | ||
public void test1() throws IOException { | ||
String query = "SELECT count(*) FROM " | ||
+ TEST_INDEX_BEER + " WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
assertNotEquals(0, result.getInt("total")); | ||
} | ||
|
||
@Test | ||
public void verify_wildcard_test() throws IOException { | ||
String query1 = "SELECT count(*) FROM " | ||
+ TEST_INDEX_BEER + " WHERE simple_query_string(['Tags'], 'taste')"; | ||
var result1 = new JSONObject(executeQuery(query1, "jdbc")); | ||
String query2 = "SELECT count(*) FROM " | ||
+ TEST_INDEX_BEER + " WHERE simple_query_string(['T*'], 'taste')"; | ||
var result2 = new JSONObject(executeQuery(query2, "jdbc")); | ||
assertNotEquals(result2.getInt("total"), result1.getInt("total")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.