Search in sources :

Example 6 with MultiSearchResult

use of io.searchbox.core.MultiSearchResult 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 [[].");
}
Also used : MultiSearchResult(io.searchbox.core.MultiSearchResult) QueryResult(org.graylog.plugins.views.search.QueryResult) SearchError(org.graylog.plugins.views.search.errors.SearchError) Test(org.junit.Test)

Example 7 with MultiSearchResult

use of io.searchbox.core.MultiSearchResult in project graylog2-server by Graylog2.

the class ElasticsearchBackendTestBase method resultFor.

MultiSearchResult resultFor(String result) {
    final ObjectMapper objectMapper = objectMapperProvider.get();
    final MultiSearchResult multiSearchResult = new MultiSearchResult(objectMapper);
    multiSearchResult.setSucceeded(true);
    try {
        multiSearchResult.setJsonObject(objectMapper.readTree(result));
        return multiSearchResult;
    } catch (IOException e) {
    }
    return null;
}
Also used : MultiSearchResult(io.searchbox.core.MultiSearchResult) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

MultiSearchResult (io.searchbox.core.MultiSearchResult)7 QueryResult (org.graylog.plugins.views.search.QueryResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 MultiSearch (io.searchbox.core.MultiSearch)2 Search (io.searchbox.core.Search)2 SearchError (org.graylog.plugins.views.search.errors.SearchError)2 SearchSourceBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Maps (com.google.common.collect.Maps)1 Named (com.google.inject.name.Named)1 JestClient (io.searchbox.client.JestClient)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1