use of org.graylog.storage.elasticsearch7.views.searchtypes.ESMessageList 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.searchtypes.ESMessageList 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());
}
use of org.graylog.storage.elasticsearch7.views.searchtypes.ESMessageList in project graylog2-server by Graylog2.
the class ESMessageList method doExtractResult.
@Override
public SearchType.Result doExtractResult(SearchJob job, Query query, MessageList searchType, org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchResponse result, Aggregations aggregations, ESGeneratedQueryContext queryContext) {
final List<ResultMessageSummary> messages = StreamSupport.stream(result.getHits().spliterator(), false).map(ESMessageList::resultMessageFromSearchHit).map((resultMessage) -> ResultMessageSummary.create(resultMessage.highlightRanges, resultMessage.getMessage().getFields(), resultMessage.getIndex())).collect(Collectors.toList());
final String undecoratedQueryString = query.query().queryString();
final String queryString = this.esQueryDecorators.decorate(undecoratedQueryString, job, query);
final DateTime from = query.effectiveTimeRange(searchType).getFrom();
final DateTime to = query.effectiveTimeRange(searchType).getTo();
final SearchResponse searchResponse = SearchResponse.create(undecoratedQueryString, queryString, Collections.emptySet(), messages, Collections.emptySet(), 0, result.getHits().getTotalHits().value, from, to);
final SearchResponse decoratedSearchResponse = decoratorProcessor.decorateSearchResponse(searchResponse, searchType.decorators());
final MessageList.Result.Builder resultBuilder = MessageList.Result.result(searchType.id()).messages(decoratedSearchResponse.messages()).effectiveTimerange(AbsoluteRange.create(from, to)).totalResults(decoratedSearchResponse.totalResults());
return searchType.name().map(resultBuilder::name).orElse(resultBuilder).build();
}
Aggregations