Skip to content

Commit

Permalink
fix format issue
Browse files Browse the repository at this point in the history
Signed-off-by: zane-neo <[email protected]>
  • Loading branch information
zane-neo authored and xinyual committed Oct 8, 2023
1 parent a69c6b4 commit 43fabfb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ public void testHashAndEquals() {
.queryName(queryName1);

// Identical to sparseEncodingQueryBuilder_baseline except default boost and query name
NeuralSparseQueryBuilder sparseEncodingQueryBuilder_defaultBoostAndQueryName = new NeuralSparseQueryBuilder().fieldName(
fieldName1
).queryText(queryText1).modelId(modelId1);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder_defaultBoostAndQueryName = new NeuralSparseQueryBuilder().fieldName(fieldName1)
.queryText(queryText1)
.modelId(modelId1);

// Identical to sparseEncodingQueryBuilder_baseline except diff field name
NeuralSparseQueryBuilder sparseEncodingQueryBuilder_diffFieldName = new NeuralSparseQueryBuilder().fieldName(fieldName2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public void tearDown() {
public void testBasicQueryUsingQueryText() {
initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME);
String modelId = getDeployedModelId();
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1
).queryText(TEST_QUERY_TEXT).modelId(modelId);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId);
Map<String, Object> searchResponseAsMap = search(TEST_BASIC_INDEX_NAME, sparseEncodingQueryBuilder, 1);
Map<String, Object> firstInnerHit = getFirstInnerHit(searchResponseAsMap);

Expand All @@ -96,8 +97,10 @@ public void testBasicQueryUsingQueryText() {
public void testBoostQuery() {
initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME);
String modelId = getDeployedModelId();
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1
).queryText(TEST_QUERY_TEXT).modelId(modelId).boost(2.0f);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId)
.boost(2.0f);
Map<String, Object> searchResponseAsMap = search(TEST_BASIC_INDEX_NAME, sparseEncodingQueryBuilder, 1);
Map<String, Object> firstInnerHit = getFirstInnerHit(searchResponseAsMap);

Expand Down Expand Up @@ -131,8 +134,9 @@ public void testRescoreQuery() {
initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME);
String modelId = getDeployedModelId();
MatchAllQueryBuilder matchAllQueryBuilder = new MatchAllQueryBuilder();
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1
).queryText(TEST_QUERY_TEXT).modelId(modelId);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId);
Map<String, Object> searchResponseAsMap = search(TEST_BASIC_INDEX_NAME, matchAllQueryBuilder, sparseEncodingQueryBuilder, 1);
Map<String, Object> firstInnerHit = getFirstInnerHit(searchResponseAsMap);

Expand Down Expand Up @@ -170,10 +174,12 @@ public void testBooleanQuery_withMultipleSparseEncodingQueries() {
String modelId = getDeployedModelId();
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();

NeuralSparseQueryBuilder sparseEncodingQueryBuilder1 = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1
).queryText(TEST_QUERY_TEXT).modelId(modelId);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder2 = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_2
).queryText(TEST_QUERY_TEXT).modelId(modelId);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder1 = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder2 = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_2)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId);

boolQueryBuilder.should(sparseEncodingQueryBuilder1).should(sparseEncodingQueryBuilder2);

Expand Down Expand Up @@ -214,8 +220,9 @@ public void testBooleanQuery_withSparseEncodingAndBM25Queries() {
String modelId = getDeployedModelId();
BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();

NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1
).queryText(TEST_QUERY_TEXT).modelId(modelId);
NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1)
.queryText(TEST_QUERY_TEXT)
.modelId(modelId);
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT);
boolQueryBuilder.should(sparseEncodingQueryBuilder).should(matchQueryBuilder);

Expand Down

0 comments on commit 43fabfb

Please sign in to comment.