Skip to content

Commit

Permalink
Integ tests
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Jain <[email protected]>
  • Loading branch information
vibrantvarun committed Jun 11, 2024
1 parent f8d4930 commit 291294a
Show file tree
Hide file tree
Showing 9 changed files with 658 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ private void testPostFilterWithSimpleHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
rangeFilterQuery
rangeFilterQuery,
null
);

assertHitResultsFromQuery(1, searchResponseAsMap);
Expand All @@ -229,6 +230,7 @@ private void testPostFilterWithSimpleHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
null,
null
);
assertHitResultsFromQuery(2, searchResponseAsMap);
Expand All @@ -240,7 +242,8 @@ private void testPostFilterWithSimpleHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
rangeFilterQuery
rangeFilterQuery,
null
);
assertHitResultsFromQuery(2, searchResponseAsMap);
} else {
Expand All @@ -251,6 +254,7 @@ private void testPostFilterWithSimpleHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
null,
null
);
assertHitResultsFromQuery(3, searchResponseAsMap);
Expand Down Expand Up @@ -309,7 +313,8 @@ private void testPostFilterWithComplexHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
rangeFilterQuery
rangeFilterQuery,
null
);

assertHitResultsFromQuery(1, searchResponseAsMap);
Expand All @@ -321,6 +326,7 @@ private void testPostFilterWithComplexHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
null,
null
);
assertHitResultsFromQuery(2, searchResponseAsMap);
Expand All @@ -332,7 +338,8 @@ private void testPostFilterWithComplexHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
rangeFilterQuery
rangeFilterQuery,
null
);
assertHitResultsFromQuery(4, searchResponseAsMap);
} else {
Expand All @@ -343,6 +350,7 @@ private void testPostFilterWithComplexHybridQuery(boolean isSingleShard, boolean
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
null,
null
);
assertHitResultsFromQuery(3, searchResponseAsMap);
Expand Down Expand Up @@ -514,7 +522,15 @@ private void initializeIndexIfNotExist(String indexName) throws IOException {
&& !indexExists(TEST_MULTI_DOC_INDEX_WITH_TEXT_AND_INT_MULTIPLE_SHARDS)) {
createIndexWithConfiguration(
indexName,
buildIndexConfiguration(List.of(), List.of(), List.of(INTEGER_FIELD_1), List.of(KEYWORD_FIELD_1), List.of(DATE_FIELD_1), 3),
buildIndexConfiguration(
List.of(),
List.of(),
List.of(INTEGER_FIELD_1),
List.of(KEYWORD_FIELD_1),
List.of(DATE_FIELD_1),
List.of(),
3
),
""
);

Expand Down Expand Up @@ -622,7 +638,7 @@ private void initializeIndexWithOneShardIfNotExists(String indexName) {
if (!indexExists(indexName)) {
createIndexWithConfiguration(
indexName,
buildIndexConfiguration(List.of(), List.of(), List.of(INTEGER_FIELD_1), List.of(KEYWORD_FIELD_1), List.of(), 1),
buildIndexConfiguration(List.of(), List.of(), List.of(INTEGER_FIELD_1), List.of(KEYWORD_FIELD_1), List.of(), List.of(), 1),
""
);

Expand Down
20 changes: 18 additions & 2 deletions src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,15 @@ private void initializeIndexIfNotExist(String indexName) throws IOException {
if (TEST_INDEX_WITH_KEYWORDS_ONE_SHARD.equals(indexName) && !indexExists(TEST_INDEX_WITH_KEYWORDS_ONE_SHARD)) {
createIndexWithConfiguration(
indexName,
buildIndexConfiguration(List.of(), List.of(), List.of(INTEGER_FIELD_PRICE), List.of(KEYWORD_FIELD_1), List.of(), 1),
buildIndexConfiguration(
List.of(),
List.of(),
List.of(INTEGER_FIELD_PRICE),
List.of(KEYWORD_FIELD_1),
List.of(),
List.of(),
1
),
""
);
addDocWithKeywordsAndIntFields(
Expand Down Expand Up @@ -859,7 +867,15 @@ private void initializeIndexIfNotExist(String indexName) throws IOException {
if (TEST_INDEX_WITH_KEYWORDS_THREE_SHARDS.equals(indexName) && !indexExists(TEST_INDEX_WITH_KEYWORDS_THREE_SHARDS)) {
createIndexWithConfiguration(
indexName,
buildIndexConfiguration(List.of(), List.of(), List.of(INTEGER_FIELD_PRICE), List.of(KEYWORD_FIELD_1), List.of(), 3),
buildIndexConfiguration(
List.of(),
List.of(),
List.of(INTEGER_FIELD_PRICE),
List.of(KEYWORD_FIELD_1),
List.of(),
List.of(),
3
),
""
);
addDocWithKeywordsAndIntFields(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ private void testPostFilterRangeQuery(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 1, 0, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);
}
Expand Down Expand Up @@ -256,7 +257,8 @@ private void testPostFilterBoolQuery(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 2, 1, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);
// Case 2 A Query with a combination of hybrid query (Match Query, Term Query, Range Query), aggregation (Average stock price
Expand All @@ -269,7 +271,8 @@ private void testPostFilterBoolQuery(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
List.of(aggsBuilder),
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 2, 1, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);
Map<String, Object> aggregations = getAggregations(searchResponseAsMap);
Expand All @@ -291,7 +294,8 @@ private void testPostFilterBoolQuery(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 0, 0, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);
// Case 4 A Query with a combination of hybrid query (Match Query, Range Query) and a post filter query (Bool Query with a should
Expand All @@ -309,7 +313,8 @@ private void testPostFilterBoolQuery(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 0, 0, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);
}
Expand Down Expand Up @@ -364,7 +369,8 @@ private void testPostFilterMatchAllAndMatchNoneQueries(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 4, 3, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);

Expand All @@ -378,7 +384,8 @@ private void testPostFilterMatchAllAndMatchNoneQueries(String indexName) {
10,
Map.of("search_pipeline", SEARCH_PIPELINE),
null,
postFilterQuery
postFilterQuery,
null
);
assertHybridQueryResults(searchResponseAsMap, 0, 0, GTE_OF_RANGE_IN_POST_FILTER_QUERY, LTE_OF_RANGE_IN_POST_FILTER_QUERY);
}
Expand Down Expand Up @@ -424,6 +431,7 @@ private void initializeIndexIfNotExists(String indexName, int numShards) {
List.of(INTEGER_FIELD_1_STOCK),
List.of(KEYWORD_FIELD_2_CATEGORY),
List.of(),
List.of(TEXT_FIELD_1_NAME),
numShards
),
""
Expand Down
Loading

0 comments on commit 291294a

Please sign in to comment.