use of org.graylog.storage.elasticsearch7.views.ESGeneratedQueryContext 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.storage.elasticsearch7.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);
backend = new ElasticsearchBackend(handlers, null, mock(IndexLookup.class), new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false);
}
use of org.graylog.storage.elasticsearch7.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.elasticsearch7.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.elasticsearch7.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");
}
Aggregations