use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendMultiSearchTest method everySearchTypeGeneratesASearchSourceBuilder.
@Test
public void everySearchTypeGeneratesASearchSourceBuilder() {
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
assertThat(queryContext.searchTypeQueries()).hasSize(2).containsOnlyKeys("pivot1", "pivot2");
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendMultiSearchTest method everySearchTypeGeneratesOneESQuery.
@Test
public void everySearchTypeGeneratesOneESQuery() throws Exception {
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
when(jestClient.execute(any(), any())).thenReturn(resultFor(resourceFile("successfulMultiSearchResponse.json")));
final String generatedRequest = run(searchJob, query, queryContext, Collections.emptySet());
assertThat(generatedRequest).isEqualTo(resourceFile("everySearchTypeGeneratesOneESQuery.request.ndjson"));
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendMultiSearchTest method multiSearchResultsAreAssignedToSearchTypes.
@Test
public void multiSearchResultsAreAssignedToSearchTypes() throws Exception {
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
when(jestClient.execute(any(), any())).thenReturn(resultFor(resourceFile("successfulMultiSearchResponse.json")));
final QueryResult queryResult = this.elasticsearchBackend.doRun(searchJob, query, queryContext);
assertThat(queryResult.searchTypes()).containsOnlyKeys("pivot1", "pivot2");
final PivotResult pivot1Result = (PivotResult) queryResult.searchTypes().get("pivot1");
assertThat(pivot1Result.rows().get(0)).isEqualTo(PivotResult.Row.builder().key(ImmutableList.of()).source("leaf").addValue(PivotResult.Value.create(Collections.singletonList("avg(field1)"), 27220.273504273504, true, "row-leaf")).build());
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 ElasticsearchBackendQueryStringDecoratorsTest method generateJsonRequest.
private DocumentContext generateJsonRequest(Query query, SearchJob searchJob) {
final ESGeneratedQueryContext context = this.backend.generate(searchJob, query, new SearchConfig(Period.ZERO));
final String request = context.searchTypeQueries().get("testSearchtype").toString();
return JsonPath.parse(request);
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method run.
private MultiSearch 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(jestClient, times(1)).execute(clientRequestCaptor.capture(), any());
return clientRequestCaptor.getValue();
}
Aggregations