use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendMultiSearchTest method oneFailingSearchTypeReturnsPartialResults.
@Test
public void oneFailingSearchTypeReturnsPartialResults() throws Exception {
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
when(jestClient.execute(any(), any())).thenReturn(resultFor(resourceFile("partiallySuccessfulMultiSearchResponse.json")));
final QueryResult queryResult = this.elasticsearchBackend.doRun(searchJob, query, queryContext);
assertThat(queryResult.errors()).hasSize(1);
final SearchTypeError searchTypeError = (SearchTypeError) new ArrayList<>(queryResult.errors()).get(0);
assertThat(searchTypeError.description()).isEqualTo("Unable to perform search query: \n" + "\n" + "Expected numeric type on field [field1], but got [keyword].");
assertThat(searchTypeError.searchTypeId()).isEqualTo("pivot1");
assertThat(queryResult.searchTypes()).containsOnlyKeys("pivot2");
final PivotResult pivot2Result = (PivotResult) queryResult.searchTypes().get("pivot2");
assertThat(pivot2Result.rows().get(0)).isEqualTo(PivotResult.Row.builder().key(ImmutableList.of()).source("leaf").addValue(PivotResult.Value.create(Collections.singletonList("max(field2)"), 42.0, true, "row-leaf")).build());
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendTest method generatesSearchForEmptySearchTypes.
@Test
public void generatesSearchForEmptySearchTypes() throws Exception {
final Query query = Query.builder().id("query1").query(ElasticsearchQueryString.of("")).timerange(RelativeRange.create(300)).build();
final Search search = Search.builder().queries(ImmutableSet.of(query)).build();
final SearchJob job = new SearchJob("deadbeef", search, "admin");
backend.generate(job, query, new SearchConfig(Period.ZERO));
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method queryUsesCorrectTimerangeWhenDeterminingIndexRanges.
@Test
public void queryUsesCorrectTimerangeWhenDeterminingIndexRanges() throws Exception {
final long datetimeFixture = 1530194810;
DateTimeUtils.setCurrentMillisFixed(datetimeFixture);
final ESGeneratedQueryContext context = backend.generate(job, query, new SearchConfig(Period.ZERO));
backend.doRun(job, query, context);
ArgumentCaptor<TimeRange> captor = ArgumentCaptor.forClass(TimeRange.class);
verify(indexLookup, times(1)).indexNamesForStreamsInTimeRange(any(), captor.capture());
assertThat(captor.getValue()).isEqualTo(RelativeRange.create(600));
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method queryUsesOnlyIndicesIncludingTimerangeAndStream.
@Test
public void queryUsesOnlyIndicesIncludingTimerangeAndStream() throws Exception {
final String streamId = "streamId";
final Query query = dummyQuery(RelativeRange.create(600)).toBuilder().filter(StreamFilter.ofId(streamId)).build();
final Search search = dummySearch(query);
final SearchJob job = new SearchJob("job1", search, "admin");
final ESGeneratedQueryContext context = backend.generate(job, query, new SearchConfig(Period.ZERO));
when(indexLookup.indexNamesForStreamsInTimeRange(ImmutableSet.of("streamId"), RelativeRange.create(600))).thenReturn(ImmutableSet.of("index1", "index2"));
backend.doRun(job, query, context);
verify(jestClient, times(1)).execute(clientRequestCaptor.capture(), any());
final MultiSearch clientRequest = clientRequestCaptor.getValue();
assertThat(clientRequest).isNotNull();
assertThat(indicesOf(clientRequest).get(0)).isEqualTo("index1,index2");
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method run.
private List<SearchRequest> run(Query query) throws IOException {
final SearchJob job = searchJobForQuery(query);
final ESGeneratedQueryContext context = this.elasticsearchBackend.generate(job, query, new SearchConfig(Period.ZERO));
this.elasticsearchBackend.doRun(job, query, context);
verify(client, times(1)).msearch(clientRequestCaptor.capture(), any());
return clientRequestCaptor.getValue();
}
Aggregations