use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class SearchDriver method allMessagesJson.
private static String allMessagesJson(String queryId, String messageListId, TimeRange timeRange) {
MessageList messageList = MessageList.builder().id(messageListId).build();
QueryDTO q = QueryDTO.builder().id(queryId).query(ElasticsearchQueryString.of("")).timerange(timeRange).searchTypes(ImmutableSet.of(messageList)).build();
SearchDTO s = SearchDTO.builder().id(new ObjectId().toHexString()).queries(ImmutableSet.of(q)).build();
return JsonUtils.toJsonString(s);
}
use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class ESMessageListTest method doesNotUseHighlightingIfDeactivatedInConfig.
@Test
public void doesNotUseHighlightingIfDeactivatedInConfig() {
MessageList messageList = someMessageList();
ESGeneratedQueryContext context = generateQueryPartWithoutHighlighting(messageList);
assertThat(context.searchSourceBuilder(messageList).highlighter()).as("there should be no highlighter configured").isNull();
}
use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.
the class ESMessageListTest method passesNullForUnmappedTypeIfTypeIsNotFound.
@Test
public void passesNullForUnmappedTypeIfTypeIsNotFound() {
final MessageList messageList = someMessageListWithSorting("stream1", "somefield");
final ESGeneratedQueryContext context = mockQueryContext(messageList);
when(context.fieldType(Collections.singleton("stream1"), "somefield")).thenReturn(Optional.empty());
final ESGeneratedQueryContext queryContext = generateQueryPartWithContextFor(messageList, true, Collections.emptySet(), context);
final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
assertThat(doc.read("$.sort[0].somefield", Map.class)).doesNotContainKey("unmapped_type");
}
use of org.graylog.plugins.views.search.searchtypes.MessageList 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.searchtypes.MessageList in project graylog2-server by Graylog2.
the class ESMessageListTest method passesTypeOfSortingFieldAsUnmappedType.
@Test
public void passesTypeOfSortingFieldAsUnmappedType() {
final MessageList messageList = someMessageListWithSorting("stream1", "somefield");
final ESGeneratedQueryContext context = mockQueryContext(messageList);
when(context.fieldType(Collections.singleton("stream1"), "somefield")).thenReturn(Optional.of("long"));
final ESGeneratedQueryContext queryContext = generateQueryPartWithContextFor(messageList, true, Collections.emptySet(), context);
final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
JsonPathAssert.assertThat(doc).jsonPathAsString("$.sort[0].somefield.unmapped_type").isEqualTo("long");
}
Aggregations