Skip to content

Commit

Permalink
Remove explicit SearchResponse references from `org.elasticsearch.ind…
Browse files Browse the repository at this point in the history
…ices` and `org.elasticsearch.indexing` (#102536)
  • Loading branch information
iverase authored Nov 24, 2023
1 parent 2bd0a70 commit b12b38c
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.mapper.DocumentParsingException;
Expand All @@ -28,6 +27,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicIntegerArray;

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
Expand Down Expand Up @@ -55,17 +55,18 @@ public void testAutoGenerateIdNoDuplicates() throws Exception {
for (int j = 0; j < numOfChecks; j++) {
try {
logger.debug("running search with all types");
SearchResponse response = prepareSearch("test").get();
if (response.getHits().getTotalHits().value != numOfDocs) {
final String message = "Count is "
+ response.getHits().getTotalHits().value
+ " but "
+ numOfDocs
+ " was expected. "
+ ElasticsearchAssertions.formatShardStatus(response);
logger.error("{}. search response: \n{}", message, response);
fail(message);
}
assertResponse(prepareSearch("test"), response -> {
if (response.getHits().getTotalHits().value != numOfDocs) {
final String message = "Count is "
+ response.getHits().getTotalHits().value
+ " but "
+ numOfDocs
+ " was expected. "
+ ElasticsearchAssertions.formatShardStatus(response);
logger.error("{}. search response: \n{}", message, response);
fail(message);
}
});
} catch (Exception e) {
logger.error("search for all docs types failed", e);
if (firstError == null) {
Expand All @@ -74,17 +75,18 @@ public void testAutoGenerateIdNoDuplicates() throws Exception {
}
try {
logger.debug("running search with a specific type");
SearchResponse response = prepareSearch("test").get();
if (response.getHits().getTotalHits().value != numOfDocs) {
final String message = "Count is "
+ response.getHits().getTotalHits().value
+ " but "
+ numOfDocs
+ " was expected. "
+ ElasticsearchAssertions.formatShardStatus(response);
logger.error("{}. search response: \n{}", message, response);
fail(message);
}
assertResponse(prepareSearch("test"), response -> {
if (response.getHits().getTotalHits().value != numOfDocs) {
final String message = "Count is "
+ response.getHits().getTotalHits().value
+ " but "
+ numOfDocs
+ " was expected. "
+ ElasticsearchAssertions.formatShardStatus(response);
logger.error("{}. search response: \n{}", message, response);
fail(message);
}
});
} catch (Exception e) {
logger.error("search for all docs of a specific type failed", e);
if (firstError == null) {
Expand Down
Loading

0 comments on commit b12b38c

Please sign in to comment.