Search in sources :

Example 6 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.elasticsearch6.views.ESGeneratedQueryContext) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) Test(org.junit.Test)

Example 7 with MessageList

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 SearchResult result = new MockSearchResult(Collections.emptyList(), (long) 0);
    final SearchType.Result searchTypeResult = esMessageList.doExtractResult(null, someQuery(), messageList, result, null, null);
    assertThat(searchTypeResult.name()).contains("customResult");
}
Also used : QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) SearchResult(io.searchbox.core.SearchResult) SearchType(org.graylog.plugins.views.search.SearchType) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) Test(org.junit.Test)

Example 8 with MessageList

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");
}
Also used : ESGeneratedQueryContext(org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext) DocumentContext(com.jayway.jsonpath.DocumentContext) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) Test(org.junit.Test)

Example 9 with MessageList

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

Example 10 with MessageList

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

the class CommandFactoryTest method takesStreamsFromQueryIfEmptyOnSearchType.

@Test
void takesStreamsFromQueryIfEmptyOnSearchType() {
    MessageList ml = MessageList.builder().id("ml-id").build();
    Query q = validQueryBuilderWith(ml).filter(streamFilter("stream-3")).build();
    Search s = searchWithQueries(q);
    ExportMessagesCommand command = buildFrom(s, ml.id());
    assertThat(command.streams()).isEqualTo(q.usedStreamIds());
}
Also used : Query(org.graylog.plugins.views.search.Query) Search(org.graylog.plugins.views.search.Search) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) Test(org.junit.jupiter.api.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