use of org.graylog.plugins.views.search.errors.SearchError in project graylog2-server by Graylog2.
the class ElasticsearchBackendErrorHandlingTest method deduplicateShardErrorsOnSearchTypeLevel.
@Test
public void deduplicateShardErrorsOnSearchTypeLevel() throws IOException {
final MultiSearchResponse multiSearchResult = TestMultisearchResponse.fromFixture("errorhandling/failureOnSearchTypeLevel.json");
final List<MultiSearchResponse.Item> items = Arrays.stream(multiSearchResult.getResponses()).collect(Collectors.toList());
when(client.msearch(any(), any())).thenReturn(items);
final QueryResult queryResult = this.backend.doRun(searchJob, query, queryContext);
final Set<SearchError> errors = queryResult.errors();
assertThat(errors).isNotNull();
assertThat(errors).hasSize(1);
assertThat(errors.stream().map(SearchError::description).collect(Collectors.toList())).containsExactly("Unable to perform search query: " + "\n\nElasticsearch exception [type=query_shard_exception, reason=Failed to parse query [[]].");
}
use of org.graylog.plugins.views.search.errors.SearchError in project graylog2-server by Graylog2.
the class QueryEngine method execute.
public SearchJob execute(SearchJob searchJob) {
searchJob.getSearch().queries().forEach(query -> searchJob.addQueryResultFuture(query.id(), // if need be we default to an empty result with a failed state and the wrapped exception
CompletableFuture.supplyAsync(() -> prepareAndRun(searchJob, query), queryPool).handle((queryResult, throwable) -> {
if (throwable != null) {
final Throwable cause = throwable.getCause();
final SearchError error;
if (cause instanceof SearchException) {
error = ((SearchException) cause).error();
} else {
error = new QueryError(query, cause);
}
LOG.debug("Running query {} failed: {}", query.id(), cause);
searchJob.addError(error);
return QueryResult.failedQueryWithError(query, error);
}
return queryResult;
})));
searchJob.getSearch().queries().forEach(query -> {
final CompletableFuture<QueryResult> queryResultFuture = searchJob.getQueryResultFuture(query.id());
if (!queryResultFuture.isDone()) {
// this is not going to throw an exception, because we will always replace it with a placeholder "FAILED" result above
final QueryResult result = queryResultFuture.join();
} else {
LOG.debug("[{}] Not generating query for query {}", defaultIfEmpty(query.id(), "root"), query);
}
});
LOG.debug("Search job {} executing", searchJob.getId());
return searchJob.seal();
}
use of org.graylog.plugins.views.search.errors.SearchError in project graylog2-server by Graylog2.
the class ElasticsearchBackendErrorHandlingTest method deduplicateNumericShardErrorsOnSearchTypeLevel.
@Test
public void deduplicateNumericShardErrorsOnSearchTypeLevel() throws IOException {
final MultiSearchResult multiSearchResult = searchResultFromFixture("errorhandling/numericFailureOnSearchTypeLevel.json");
when(jestClient.execute(any())).thenReturn(multiSearchResult);
final QueryResult queryResult = this.backend.doRun(searchJob, query, queryContext);
final Set<SearchError> errors = queryResult.errors();
assertThat(errors).isNotNull();
assertThat(errors).hasSize(1);
assertThat(errors.stream().map(SearchError::description).collect(Collectors.toList())).containsExactly("Unable to perform search query: \n\nExpected numeric type on field [facility], but got [keyword].");
}
use of org.graylog.plugins.views.search.errors.SearchError in project graylog2-server by Graylog2.
the class ElasticsearchBackendErrorHandlingTest method deduplicateShardErrorsOnSearchTypeLevel.
@Test
public void deduplicateShardErrorsOnSearchTypeLevel() throws IOException {
final MultiSearchResult multiSearchResult = searchResultFromFixture("errorhandling/failureOnSearchTypeLevel.json");
when(jestClient.execute(any())).thenReturn(multiSearchResult);
final QueryResult queryResult = this.backend.doRun(searchJob, query, queryContext);
final Set<SearchError> errors = queryResult.errors();
assertThat(errors).isNotNull();
assertThat(errors).hasSize(1);
assertThat(errors.stream().map(SearchError::description).collect(Collectors.toList())).containsExactly("Unable to perform search query: \n\nFailed to parse query [[].");
}
use of org.graylog.plugins.views.search.errors.SearchError in project graylog2-server by Graylog2.
the class ElasticsearchBackendErrorHandlingTest method deduplicateNumericShardErrorsOnSearchTypeLevel.
@Test
public void deduplicateNumericShardErrorsOnSearchTypeLevel() throws IOException {
final MultiSearchResponse multiSearchResult = TestMultisearchResponse.fromFixture("errorhandling/numericFailureOnSearchTypeLevel.json");
final List<MultiSearchResponse.Item> items = Arrays.stream(multiSearchResult.getResponses()).collect(Collectors.toList());
when(client.msearch(any(), any())).thenReturn(items);
final QueryResult queryResult = this.backend.doRun(searchJob, query, queryContext);
final Set<SearchError> errors = queryResult.errors();
assertThat(errors).isNotNull();
assertThat(errors).hasSize(1);
assertThat(errors.stream().map(SearchError::description).collect(Collectors.toList())).containsExactly("Unable to perform search query: " + "\n\nElasticsearch exception [type=illegal_argument_exception, reason=Expected numeric type on field [facility], but got [keyword]].");
}
Aggregations