use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ElasticsearchBackendQueryStringDecoratorsTest method setUp.
@BeforeEach
void setUp() {
final QueryStringDecorator decorator = (queryString, job, query) -> "decorated";
final Set<QueryStringDecorator> decorators = Collections.singleton(decorator);
final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
this.backend = new ElasticsearchBackend(Collections.emptyMap(), mock(ElasticsearchClient.class), mock(IndexLookup.class), new QueryStringDecorators(decorators), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), true);
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ESMessageListTest method generateQueryPartWithContextFor.
private ESGeneratedQueryContext generateQueryPartWithContextFor(MessageList messageList, boolean allowHighlighting, Set<QueryStringDecorator> decorators, ESGeneratedQueryContext context) {
ESMessageList sut = new ESMessageList(new QueryStringDecorators(decorators), new LegacyDecoratorProcessor.Fake(), allowHighlighting);
sut.doGenerateQueryPart(mock(SearchJob.class), someQuery(), messageList, context);
return context;
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ESMessageListTest method includesCustomNameInResultIfPresent.
@Test
public void includesCustomNameInResultIfPresent() {
final ESMessageList esMessageList = new ESMessageList(new QueryStringDecorators(Collections.emptySet()));
final MessageList messageList = someMessageList().toBuilder().name("customResult").build();
final org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchResponse result = mock(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchResponse.class);
when(result.getHits()).thenReturn(SearchHits.empty());
final SearchType.Result searchTypeResult = esMessageList.doExtractResult(null, someQuery(), messageList, result, null, null);
assertThat(searchTypeResult.name()).contains("customResult");
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ElasticsearchBackendErrorHandlingTest method setUp.
@Before
public void setUp() throws Exception {
final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
this.backend = new ElasticsearchBackend(ImmutableMap.of("dummy", () -> mock(DummyHandler.class)), jestClient, indexLookup, new QueryStringDecorators(Collections.emptySet()), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false, objectMapper);
when(indexLookup.indexNamesForStreamsInTimeRange(any(), any())).thenReturn(Collections.emptySet());
final SearchType searchType1 = mock(SearchType.class);
when(searchType1.id()).thenReturn("deadbeef");
when(searchType1.type()).thenReturn("dummy");
final SearchType searchType2 = mock(SearchType.class);
when(searchType2.id()).thenReturn("cafeaffe");
when(searchType2.type()).thenReturn("dummy");
final Set<SearchType> searchTypes = ImmutableSet.of(searchType1, searchType2);
this.query = Query.builder().id("query1").timerange(RelativeRange.create(300)).query(ElasticsearchQueryString.of("*")).searchTypes(searchTypes).build();
final Search search = Search.builder().id("search1").queries(ImmutableSet.of(query)).build();
this.searchJob = new SearchJob("job1", search, "admin");
this.queryContext = new ESGeneratedQueryContext(this.backend, new SearchSourceBuilder(), searchJob, query, mock(FieldTypesLookup.class));
searchTypes.forEach(queryContext::searchSourceBuilder);
when(jestClient.execute(any())).thenReturn(result);
}
use of org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators in project graylog2-server by Graylog2.
the class ElasticsearchBackendQueryStringDecoratorsTest method setUp.
@BeforeEach
void setUp() {
final QueryStringDecorator decorator = (queryString, job, query) -> "decorated";
final Set<QueryStringDecorator> decorators = Collections.singleton(decorator);
final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
this.backend = new ElasticsearchBackend(Collections.emptyMap(), mock(JestClient.class), mock(IndexLookup.class), new QueryStringDecorators(decorators), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), true, new ObjectMapperProvider().get());
}
Aggregations