Search in sources :

Example 1 with SearchType

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

the class ElasticsearchBackendQueryStringDecoratorsTest method searchJobWithRootQueryString.

private SearchJob searchJobWithRootQueryString(Query query) throws InvalidRangeParametersException {
    final SearchType searchType = basicSearchType();
    final SearchJob searchJob = basicSearchJob(query, searchType);
    when(query.query()).thenReturn(ElasticsearchQueryString.of("*"));
    return searchJob;
}
Also used : SearchJob(org.graylog.plugins.views.search.SearchJob) SearchType(org.graylog.plugins.views.search.SearchType)

Example 2 with SearchType

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

the class ElasticsearchBackendQueryStringDecoratorsTest method searchJobWithSearchTypeQueryString.

private SearchJob searchJobWithSearchTypeQueryString(Query query) throws InvalidRangeParametersException {
    final SearchType searchType = basicSearchType();
    final SearchJob searchJob = basicSearchJob(query, searchType);
    when(query.query()).thenReturn(ElasticsearchQueryString.of("*"));
    when(searchType.query()).thenReturn(Optional.of(ElasticsearchQueryString.of("Should never show up")));
    return searchJob;
}
Also used : SearchJob(org.graylog.plugins.views.search.SearchJob) SearchType(org.graylog.plugins.views.search.SearchType)

Example 3 with SearchType

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

the class ElasticsearchBackendQueryStringDecoratorsTest method basicSearchType.

@Nonnull
private SearchType basicSearchType() {
    final SearchType searchType = mock(SearchType.class);
    when(searchType.id()).thenReturn("testSearchtype");
    return searchType;
}
Also used : SearchType(org.graylog.plugins.views.search.SearchType) Nonnull(javax.annotation.Nonnull)

Example 4 with SearchType

use of org.graylog.plugins.views.search.SearchType 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);
}
Also used : ESSearchTypeHandler(org.graylog.storage.elasticsearch7.views.searchtypes.ESSearchTypeHandler) Period(org.joda.time.Period) SearchJob(org.graylog.plugins.views.search.SearchJob) ImmutableSet(com.google.common.collect.ImmutableSet) BeforeClass(org.junit.BeforeClass) Provider(javax.inject.Provider) Query(org.graylog.plugins.views.search.Query) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Maps(com.google.common.collect.Maps) RelativeRange(org.graylog2.plugin.indexer.searches.timeranges.RelativeRange) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) SearchType(org.graylog.plugins.views.search.SearchType) ESMessageList(org.graylog.storage.elasticsearch7.views.searchtypes.ESMessageList) Map(java.util.Map) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Search(org.graylog.plugins.views.search.Search) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) QueryResult(org.graylog.plugins.views.search.QueryResult) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) Mockito.mock(org.mockito.Mockito.mock) ESMessageList(org.graylog.storage.elasticsearch7.views.searchtypes.ESMessageList) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Provider(javax.inject.Provider) BeforeClass(org.junit.BeforeClass)

Example 5 with SearchType

use of org.graylog.plugins.views.search.SearchType 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());
}
Also used : ESMessageList(org.graylog.storage.elasticsearch6.views.searchtypes.ESMessageList) ESSearchTypeHandler(org.graylog.storage.elasticsearch6.views.searchtypes.ESSearchTypeHandler) BeforeClass(org.junit.BeforeClass) Provider(javax.inject.Provider) Query(org.graylog.plugins.views.search.Query) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RelativeRange(org.graylog2.plugin.indexer.searches.timeranges.RelativeRange) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) SearchType(org.graylog.plugins.views.search.SearchType) Map(java.util.Map) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Search(org.graylog.plugins.views.search.Search) MessageList(org.graylog.plugins.views.search.searchtypes.MessageList) QueryResult(org.graylog.plugins.views.search.QueryResult) Period(org.joda.time.Period) SearchJob(org.graylog.plugins.views.search.SearchJob) ImmutableSet(com.google.common.collect.ImmutableSet) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Test(org.junit.Test) Maps(com.google.common.collect.Maps) QueryStringParser(org.graylog.plugins.views.search.elasticsearch.QueryStringParser) QueryStringDecorators(org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators) IndexLookup(org.graylog.plugins.views.search.elasticsearch.IndexLookup) Mockito.mock(org.mockito.Mockito.mock) ESMessageList(org.graylog.storage.elasticsearch6.views.searchtypes.ESMessageList) QueryStringParser(org.graylog.plugins.views.search.elasticsearch.QueryStringParser) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) FieldTypesLookup(org.graylog.plugins.views.search.elasticsearch.FieldTypesLookup) Provider(javax.inject.Provider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) BeforeClass(org.junit.BeforeClass)

Aggregations

SearchType (org.graylog.plugins.views.search.SearchType)25 Query (org.graylog.plugins.views.search.Query)16 SearchJob (org.graylog.plugins.views.search.SearchJob)13 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 QueryStringDecorators (org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators)8 Collections (java.util.Collections)7 Map (java.util.Map)7 QueryResult (org.graylog.plugins.views.search.QueryResult)7 Test (org.junit.Test)7 Inject (javax.inject.Inject)6 IndexLookup (org.graylog.plugins.views.search.elasticsearch.IndexLookup)6 List (java.util.List)5 Search (org.graylog.plugins.views.search.Search)5 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)5 MessageList (org.graylog.plugins.views.search.searchtypes.MessageList)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 Maps (com.google.common.collect.Maps)4 Named (com.google.inject.name.Named)4 Optional (java.util.Optional)4