Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integ relevance function it fix #608

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,4 @@ public void aggregateCastStatementShouldNotReturnZero() {
verifySchema(response, schema("SUM(CAST(male AS INT))", "male_sum", "integer"));
verifyDataRows(response, rows(4));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1355,8 +1355,4 @@ private double getDoubleAggregationValue(final JSONObject queryResult,

return targetField.getDouble(subFieldName);
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,4 @@ public static String getScriptAggregationKey(JSONObject aggregation, String pref
.orElseThrow(() -> new RuntimeException(
"Can't find key" + prefix + " in aggregation " + aggregation));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ public void testGroupByInQuery() {
assertThat(response.getJSONArray("datarows").length(), equalTo(8));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}

@Test
public void numberOperatorNameCaseInsensitiveTest() {
assertSchemaContains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,4 @@ private void checkSuccessfulFieldCast(SearchHit[] hits, String field, String cas
}
}
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ protected String executeQuery(String query, String requestType) {
}
}

protected JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}

protected String executeFetchQuery(String query, int fetchSize, String requestType)
throws IOException {
String endpoint = "/_plugins/_sql?format=" + requestType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,4 @@ public void selectFromSubqueryWithoutAliasShouldPass() throws IOException {
verifyDataRows(response,
rows("Lynn", "Pollard", 40));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,4 @@ public void testYearWithKeywordReturnsText() {

verifySchema(response, schema("YEAR(insert_time)", null, "integer"));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,4 @@ private SearchHits query(String query) throws IOException {
rsp);
return SearchResponse.fromXContent(parser).getHits();
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@

package org.opensearch.sql.sql;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
import static org.opensearch.sql.util.MatcherUtils.verifySchema;

import java.io.IOException;
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.opensearch.sql.legacy.SQLIntegTestCase;

public class RelevanceFunctionIT extends SQLIntegTestCase {
@Override
public void init() throws IOException {
loadIndex(Index.BANK);
loadIndex(Index.ACCOUNT);
}

@Test
void match_in_where() throws IOException {
JSONObject result = executeQuery("SELECT firstname WHERE match(lastname, 'Bates')");
public void match_in_where() throws IOException {
JSONObject result = executeJdbcRequest("SELECT firstname FROM " + TEST_INDEX_ACCOUNT + " WHERE match(lastname, 'Bates')");
verifySchema(result, schema("firstname", "text"));
verifyDataRows(result, rows("Nanette"));
}

@Test
void match_in_having() throws IOException {
JSONObject result = executeQuery("SELECT lastname HAVING match(firstname, 'Nanette')");
verifySchema(result, schema("lastname", "keyword"));
public void match_in_having() throws IOException {
JSONObject result = executeJdbcRequest("SELECT lastname FROM " + TEST_INDEX_ACCOUNT + " HAVING match(firstname, 'Nanette')");
verifySchema(result, schema("lastname", "text"));
verifyDataRows(result, rows("Bates"));
}

Expand Down