Skip to content

Commit

Permalink
Update Concurrent search related tests to use slice count > 1.
Browse files Browse the repository at this point in the history
Signed-off-by: Harish Bhakuni <[email protected]>
Signed-off-by: Jay Deng <[email protected]>
  • Loading branch information
Harish Bhakuni authored and Jay Deng committed Nov 17, 2023
1 parent 03a9650 commit 6a50b0a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void testRequestBreaker() throws Exception {
)
.get();

indexRandomForConcurrentSearch(3, "test");
try {
client().prepareSearch("test")
.addAggregation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ public void testSortByBucket() throws Exception {
}

public void testFieldCollapsing() throws Exception {
indexRandomForConcurrentSearch("field-collapsing");
SearchResponse response = client().prepareSearch("field-collapsing")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(matchQuery("text", "term rare"))
Expand Down Expand Up @@ -753,6 +754,7 @@ public void testEmptyIndex() throws Exception {
}

public void testTrackScores() throws Exception {
indexRandomForConcurrentSearch(3, "field-collapsing");
boolean[] trackScores = new boolean[] { true, false };
for (boolean trackScore : trackScores) {
logger.info("Track score={}", trackScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ public void testScriptFieldUsingSource() throws Exception {
)
.get();
client().admin().indices().refresh(refreshRequest()).actionGet();
indexRandomForConcurrentSearch(3, "test");

SearchResponse response = client().prepareSearch()
.setQuery(matchAllQuery())
Expand Down Expand Up @@ -674,6 +675,7 @@ public void testScriptFieldUsingSource() throws Exception {
public void testScriptFieldsForNullReturn() throws Exception {
client().prepareIndex("test").setId("1").setSource("foo", "bar").setRefreshPolicy("true").get();

indexRandomForConcurrentSearch(3, "test");
SearchResponse response = client().prepareSearch()
.setQuery(matchAllQuery())
.addScriptField("test_script_1", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return null", Collections.emptyMap()))
Expand Down Expand Up @@ -1271,6 +1273,7 @@ public void testScriptFields() throws Exception {
);
}
indexRandom(true, reqs);
indexRandomForConcurrentSearch("index");
ensureSearchable();
SearchRequestBuilder req = client().prepareSearch("index");
for (String field : Arrays.asList("s", "ms", "l", "ml", "d", "md")) {
Expand Down Expand Up @@ -1326,6 +1329,7 @@ public void testDocValueFieldsWithFieldAlias() throws Exception {

index("test", MapperService.SINGLE_MAPPING_NAME, "1", "text_field", "foo", "date_field", formatter.print(date));
refresh("test");
indexRandomForConcurrentSearch("test");

SearchRequestBuilder builder = client().prepareSearch()
.setQuery(matchAllQuery())
Expand Down Expand Up @@ -1440,6 +1444,7 @@ public void testStoredFieldsWithFieldAlias() throws Exception {

index("test", MapperService.SINGLE_MAPPING_NAME, "1", "field1", "value1", "field2", "value2");
refresh("test");
indexRandomForConcurrentSearch(3, "test");

SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ public void testParseGeoPoint() throws Exception {
constantScoreQuery(termQuery("test", "value")),
ScoreFunctionBuilders.weightFactorFunction(randomIntBetween(1, 10))
);
indexRandomForConcurrentSearch(3, "test");
GeoPoint point = new GeoPoint(20, 11);
ActionFuture<SearchResponse> response = client().search(
searchRequest().searchType(SearchType.QUERY_THEN_FETCH)
Expand Down Expand Up @@ -535,6 +536,7 @@ public void testCombineModes() throws Exception {
.setRefreshPolicy(IMMEDIATE)
.setSource(jsonBuilder().startObject().field("test", "value value").field("num", 1.0).endObject())
.get();
indexRandomForConcurrentSearch(3, "test");
FunctionScoreQueryBuilder baseQuery = functionScoreQuery(
constantScoreQuery(termQuery("test", "value")),
ScoreFunctionBuilders.weightFactorFunction(2)
Expand Down Expand Up @@ -654,6 +656,7 @@ public void testCombineModesExplain() throws Exception {
constantScoreQuery(termQuery("test", "value")).queryName("query1"),
ScoreFunctionBuilders.weightFactorFunction(2, "weight1")
);
indexRandomForConcurrentSearch(3, "test");
// decay score should return 0.5 for this function and baseQuery should return 2.0f as it's score
ActionFuture<SearchResponse> response = client().search(
searchRequest().searchType(SearchType.QUERY_THEN_FETCH)
Expand Down Expand Up @@ -762,6 +765,7 @@ public void testParseDateMath() throws Exception {
).actionGet();
refresh();

indexRandomForConcurrentSearch(3, "test");
SearchResponse sr = client().search(
searchRequest().source(
searchSource().query(functionScoreQuery(termQuery("test", "value"), gaussDecayFunction("num1", "now", "2d")))
Expand Down Expand Up @@ -817,6 +821,7 @@ public void testValueMissingLin() throws Exception {
).actionGet();

refresh();
indexRandomForConcurrentSearch(3, "test");

ActionFuture<SearchResponse> response = client().search(
searchRequest().searchType(SearchType.QUERY_THEN_FETCH)
Expand Down Expand Up @@ -974,6 +979,7 @@ public void testManyDocsLin() throws Exception {
List<Float> lonlat = new ArrayList<>();
lonlat.add(100f);
lonlat.add(110f);
indexRandomForConcurrentSearch(3, "test");
ActionFuture<SearchResponse> response = client().search(
searchRequest().searchType(SearchType.QUERY_THEN_FETCH)
.source(
Expand Down Expand Up @@ -1107,6 +1113,7 @@ public void testNoQueryGiven() throws Exception {
client().index(indexRequest("test").source(jsonBuilder().startObject().field("test", "value").field("num", 1.0).endObject()))
.actionGet();
refresh();
indexRandomForConcurrentSearch(3, "test");
// so, we indexed a string field, but now we try to score a num field
ActionFuture<SearchResponse> response = client().search(
searchRequest().searchType(SearchType.QUERY_THEN_FETCH)
Expand Down Expand Up @@ -1171,6 +1178,7 @@ public void testMultiFieldOptions() throws Exception {
);

indexRandom(true, doc1, doc2);
indexRandomForConcurrentSearch(3, "test");

ActionFuture<SearchResponse> response = client().search(searchRequest().source(searchSource().query(baseQuery)));
SearchResponse sr = response.actionGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public void testFieldValueFactorExplain() throws IOException {
client().prepareIndex("test").setId("3").setSource("body", "bar").get();

refresh();
indexRandomForConcurrentSearch(3, "test");

// document 2 scores higher because 17 > 5
final String functionName = "func1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public void testScriptScoresNested() throws IOException {
createIndex(INDEX);
index(INDEX, TYPE, "1", jsonBuilder().startObject().field("dummy_field", 1).endObject());
refresh();
indexRandomForConcurrentSearch(3, INDEX);

Script scriptOne = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "1", Collections.emptyMap());
Script scriptTwo = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "get score value", Collections.emptyMap());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public void testPlugin() throws Exception {
).actionGet();

client().admin().indices().prepareRefresh().get();
indexRandomForConcurrentSearch(3, "test");
DecayFunctionBuilder<?> gfb = new CustomDistanceScoreBuilder("num1", "2013-05-28", "+1d");

ActionFuture<SearchResponse> response = client().search(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void testEnforceWindowSize() {
client().prepareIndex("test").setId(Integer.toString(i)).setSource("f", Integer.toString(i)).get();
}
refresh();
indexRandomForConcurrentSearch(3, "test");

int numShards = getNumShards("test").numPrimaries;
for (int j = 0; j < iters; j++) {
Expand Down Expand Up @@ -169,6 +170,7 @@ public void testRescorePhrase() throws Exception {
.setSource("field1", "quick huge brown", "field2", "the quick lazy huge brown fox jumps over the tree")
.get();
refresh();
indexRandomForConcurrentSearch(3, "test");
SearchResponse searchResponse = client().prepareSearch()
.setQuery(QueryBuilders.matchQuery("field1", "the quick brown").operator(Operator.OR))
.setRescorer(
Expand Down Expand Up @@ -545,6 +547,7 @@ public void testExplain() throws Exception {
.setSource("field1", "quick huge brown", "field2", "the quick lazy huge brown fox jumps over the tree")
.get();
refresh();
indexRandomForConcurrentSearch(3, "test");

{
SearchResponse searchResponse = client().prepareSearch()
Expand Down Expand Up @@ -816,6 +819,7 @@ public void testFromSize() throws Exception {
client().prepareIndex("test").setId("" + i).setSource("text", "hello world").get();
}
refresh();
indexRandomForConcurrentSearch(3, "test");

SearchRequestBuilder request = client().prepareSearch();
request.setQuery(QueryBuilders.termQuery("text", "hello"));
Expand Down

0 comments on commit 6a50b0a

Please sign in to comment.