|
20 | 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
21 | 21 | import com.github.joschi.jadconfig.util.Duration; |
22 | 22 | import com.google.common.annotations.VisibleForTesting; |
23 | | -import com.google.common.collect.Streams; |
24 | 23 | import io.opentelemetry.instrumentation.annotations.WithSpan; |
25 | 24 | import jakarta.inject.Inject; |
26 | 25 | import jakarta.inject.Named; |
| 26 | +import org.graylog.plugins.views.search.errors.SearchTypeErrorParser; |
27 | 27 | import org.graylog.shaded.elasticsearch7.org.apache.http.ContentTooLongException; |
28 | 28 | import org.graylog.shaded.elasticsearch7.org.apache.http.client.config.RequestConfig; |
29 | 29 | import org.graylog.shaded.elasticsearch7.org.elasticsearch.ElasticsearchException; |
|
46 | 46 | import org.graylog2.indexer.MapperParsingException; |
47 | 47 | import org.graylog2.indexer.MasterNotDiscoveredException; |
48 | 48 | import org.graylog2.indexer.ParentCircuitBreakingException; |
| 49 | +import org.graylog2.indexer.exceptions.ResultWindowLimitExceededException; |
49 | 50 | import org.slf4j.Logger; |
50 | 51 | import org.slf4j.LoggerFactory; |
51 | 52 |
|
|
55 | 56 | import java.util.Optional; |
56 | 57 | import java.util.regex.Matcher; |
57 | 58 | import java.util.regex.Pattern; |
58 | | -import java.util.stream.Collectors; |
59 | 59 |
|
60 | 60 | import static com.google.common.base.Preconditions.checkArgument; |
61 | 61 |
|
@@ -97,21 +97,6 @@ public SearchResponse search(SearchRequest searchRequest, String errorMessage) { |
97 | 97 | return firstResponseFrom(result, errorMessage); |
98 | 98 | } |
99 | 99 |
|
100 | | - public List<MultiSearchResponse.Item> msearch(List<SearchRequest> searchRequests, String errorMessage) { |
101 | | - final MultiSearchRequest multiSearchRequest = new MultiSearchRequest(); |
102 | | - |
103 | | - indexerMaxConcurrentSearches.ifPresent(multiSearchRequest::maxConcurrentSearchRequests); |
104 | | - indexerMaxConcurrentShardRequests.ifPresent(maxShardRequests -> searchRequests |
105 | | - .forEach(request -> request.setMaxConcurrentShardRequests(maxShardRequests))); |
106 | | - |
107 | | - searchRequests.forEach(multiSearchRequest::add); |
108 | | - |
109 | | - final MultiSearchResponse result = this.execute((c, requestOptions) -> c.msearch(multiSearchRequest, requestOptions), errorMessage); |
110 | | - |
111 | | - return Streams.stream(result) |
112 | | - .collect(Collectors.toList()); |
113 | | - } |
114 | | - |
115 | 100 | private SearchResponse firstResponseFrom(MultiSearchResponse result, String errorMessage) { |
116 | 101 | checkArgument(result != null); |
117 | 102 | checkArgument(result.getResponses().length == 1); |
@@ -184,6 +169,10 @@ private RequestOptions requestOptions() { |
184 | 169 |
|
185 | 170 | public static RuntimeException exceptionFrom(Exception e, String errorMessage) { |
186 | 171 | if (e instanceof ElasticsearchException elasticsearchException) { |
| 172 | + final Integer resultWindowLimitFromError = SearchTypeErrorParser.getResultWindowLimitFromError(elasticsearchException); |
| 173 | + if (resultWindowLimitFromError != null) { |
| 174 | + throw new ResultWindowLimitExceededException(resultWindowLimitFromError); |
| 175 | + } |
187 | 176 | if (isIndexNotFoundException(elasticsearchException)) { |
188 | 177 | return IndexNotFoundException.create(errorMessage + elasticsearchException.getResourceId(), elasticsearchException.getIndex().getName()); |
189 | 178 | } |
|
0 commit comments