Skip to content

Commit

Permalink
add it
Browse files Browse the repository at this point in the history
Signed-off-by: zhichao-aws <[email protected]>
  • Loading branch information
zhichao-aws committed Sep 20, 2023
1 parent 2b7bd36 commit 91f4d1f
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.junit.After;
import org.junit.Before;
import org.opensearch.client.ResponseException;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.MatchAllQueryBuilder;
import org.opensearch.index.query.MatchQueryBuilder;
Expand Down Expand Up @@ -263,6 +264,18 @@ public void testBooleanQuery_withSparseEncodingAndBM25Queries() {
assertTrue(minExpectedScore < objectToFloat(firstInnerHit.get("_score")));
}

@SneakyThrows
public void testBasicQueryUsingQueryText_whenQueryWrongFieldType_thenFail() {
initializeIndexIfNotExist(TEST_TEXT_AND_SPARSE_ENCODING_FIELD_INDEX_NAME);
String modelId = getDeployedModelId();

SparseEncodingQueryBuilder sparseEncodingQueryBuilder = new SparseEncodingQueryBuilder().fieldName(TEST_TEXT_FIELD_NAME_1)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId);

expectThrows(ResponseException.class, () -> search(TEST_TEXT_AND_SPARSE_ENCODING_FIELD_INDEX_NAME, sparseEncodingQueryBuilder, 1));
}

@SneakyThrows
protected void initializeIndexIfNotExist(String indexName) {
if (TEST_BASIC_INDEX_NAME.equals(indexName) && !indexExists(indexName)) {
Expand Down

0 comments on commit 91f4d1f

Please sign in to comment.