Search in sources :

Example 16 with MessageList

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

the class CommandFactoryTest method combinesQueryStringIfSpecifiedOnMessageListAndQuery.

@Test
void combinesQueryStringIfSpecifiedOnMessageListAndQuery() {
    MessageList ml = MessageList.builder().id("ml-id").query(ElasticsearchQueryString.of("from-messagelist")).build();
    Query q = validQueryBuilderWith(ml).query(ElasticsearchQueryString.of("from-query")).build();
    Search s = searchWithQueries(q);
    ExportMessagesCommand command = buildFrom(s, ml.id());
    ElasticsearchQueryString combined = ElasticsearchQueryString.of("from-query AND from-messagelist");
    assertThat(command.queryString()).isEqualTo(combined);
}
Also used : Query(org.graylog.plugins.views.search.Query) Search(org.graylog.plugins.views.search.Search) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) Test(org.junit.jupiter.api.Test)

Example 17 with MessageList

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

the class CommandFactoryTest method takesStreamsFromSearchTypeIfNotEmpty.

@Test
void takesStreamsFromSearchTypeIfNotEmpty() {
    MessageList ml = MessageList.builder().id("ml-id").streams(ImmutableSet.of("stream-1", "stream-2")).build();
    Query q = validQueryBuilderWith(ml).filter(streamFilter("stream-3")).build();
    Search s = searchWithQueries(q);
    ExportMessagesCommand command = buildFrom(s, ml.id());
    assertThat(command.streams()).isEqualTo(ml.effectiveStreams());
}
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)

Example 18 with MessageList

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

the class CommandFactoryTest method takesTimeRangeFromQueryIfNotSpecifiedOnMessageList.

@Test
void takesTimeRangeFromQueryIfNotSpecifiedOnMessageList() {
    MessageList ml = MessageList.builder().id("ml-id").build();
    Query q = validQueryBuilderWith(ml).build();
    Search s = searchWithQueries(q);
    ExportMessagesCommand command = buildFrom(s, ml.id());
    assertThat(command.timeRange()).isEqualTo(q.timerange());
}
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)

Example 19 with MessageList

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

the class CommandFactoryTest method takesQueryStringFromMessageListIfOnlySpecifiedThere.

@Test
void takesQueryStringFromMessageListIfOnlySpecifiedThere() {
    MessageList ml = MessageList.builder().id("ml-id").query(ElasticsearchQueryString.of("nacken")).build();
    Query q = validQueryBuilderWith(ml).build();
    Search s = searchWithQueries(q);
    ExportMessagesCommand command = buildFrom(s, ml.id());
    // noinspection OptionalGetWithoutIsPresent
    assertThat(command.queryString()).isEqualTo(ml.query().get());
}
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)

Example 20 with MessageList

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

the class CommandFactoryTest method takesFieldsFromResultFormatIfSpecified.

@Test
void takesFieldsFromResultFormatIfSpecified() {
    MessageList ml = MessageList.builder().id("ml-id").build();
    Query q = validQueryBuilderWith(ml).build();
    Search s = searchWithQueries(q);
    ResultFormat resultFormat = ResultFormat.builder().fieldsInOrder("field-1", "field-2").build();
    ExportMessagesCommand command = buildFrom(s, ml.id(), resultFormat);
    assertThat(command.fieldsInOrder()).isEqualTo(resultFormat.fieldsInOrder());
}
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