Search in sources :

Example 26 with MessageList

use of org.graylog.plugins.views.search.searchtypes.MessageList in project graylog2-server by Graylog2.

the class ESMessageListTest method appliesDecoratorsToQueryStringIfHighlightingActivated.

@Test
public void appliesDecoratorsToQueryStringIfHighlightingActivated() {
    final QueryStringDecorator queryStringDecorator = (String queryString, ParameterProvider job, Query query) -> "Foobar!";
    final MessageList messageList = someMessageList();
    ESGeneratedQueryContext queryContext = generateQueryPartWithHighlighting(messageList, Collections.singleton(queryStringDecorator));
    final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
    JsonPathAssert.assertThat(doc).jsonPathAsString("$.highlight.highlight_query.query_string.query").isEqualTo("Foobar!");
}
Also used : ParameterProvider(org.graylog.plugins.views.search.ParameterProvider) Query(org.graylog.plugins.views.search.Query) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) ESGeneratedQueryContext(org.graylog.storage.elasticsearch7.views.ESGeneratedQueryContext) DocumentContext(com.jayway.jsonpath.DocumentContext) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) QueryStringDecorator(org.graylog.plugins.views.search.engine.QueryStringDecorator) Test(org.junit.Test)

Example 27 with MessageList

use of org.graylog.plugins.views.search.searchtypes.MessageList 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();
}
Also used : ESGeneratedQueryContext(org.graylog.storage.elasticsearch7.views.ESGeneratedQueryContext) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) Test(org.junit.Test)

Aggregations

MessageList (org.graylog.plugins.views.search.searchtypes.MessageList)27 Query (org.graylog.plugins.views.search.Query)15 Test (org.junit.Test)13 Search (org.graylog.plugins.views.search.Search)10 Test (org.junit.jupiter.api.Test)10 DocumentContext (com.jayway.jsonpath.DocumentContext)6 ESGeneratedQueryContext (org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext)6 ESGeneratedQueryContext (org.graylog.storage.elasticsearch7.views.ESGeneratedQueryContext)6 SearchType (org.graylog.plugins.views.search.SearchType)5 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)4 QueryStringDecorators (org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators)4 Optional (java.util.Optional)3 AbsoluteRange (org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)2 Named (com.google.inject.name.Named)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2