use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext 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.storage.elasticsearch6.views.ESGeneratedQueryContext 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.storage.elasticsearch6.views.ESGeneratedQueryContext 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");
}
use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ElasticsearchBackendTest method setup.
@BeforeClass
public static void setup() {
Map<String, Provider<ESSearchTypeHandler<? extends SearchType>>> handlers = Maps.newHashMap();
handlers.put(MessageList.NAME, () -> new ESMessageList(new QueryStringDecorators.Fake()));
final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
final QueryStringParser queryStringParser = new QueryStringParser();
backend = new ElasticsearchBackend(handlers, null, mock(IndexLookup.class), new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false, new ObjectMapperProvider().get());
}
use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ESMessageListTest method usesHighlightingIfActivatedInConfig.
@Test
public void usesHighlightingIfActivatedInConfig() {
MessageList messageList = someMessageList();
ESGeneratedQueryContext context = generateQueryPartWithHighlighting(messageList);
assertThat(context.searchSourceBuilder(messageList).highlighter()).isNotNull();
}
Aggregations