Package org.graylog.events.search
Class MoreSearch
java.lang.Object
org.graylog.events.search.MoreSearch
This class contains search helper for the events system.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
Callback that receives message batches fromscrollQuery(String, Set, Set, TimeRange, int, ScrollCallback)
. -
Constructor Summary
ConstructorDescriptionMoreSearch
(StreamService streamService, IndexRangeService indexRangeService, QueryStringDecorators esQueryDecorators, MoreSearchAdapter moreSearchAdapter) -
Method Summary
Modifier and TypeMethodDescriptionloadStreams
(Set<String> streamIds) static String
luceneEscape
(String searchString) Helper to perform basic Lucene escaping of query string valuesvoid
scrollQuery
(String queryString, Set<String> streams, Set<Parameter> queryParameters, TimeRange timeRange, int batchSize, MoreSearch.ScrollCallback resultCallback) This scrolls results for the given query, streams and time range from Elasticsearch.
-
Constructor Details
-
MoreSearch
@Inject public MoreSearch(StreamService streamService, IndexRangeService indexRangeService, QueryStringDecorators esQueryDecorators, MoreSearchAdapter moreSearchAdapter)
-
-
Method Details
-
scrollQuery
public void scrollQuery(String queryString, Set<String> streams, Set<Parameter> queryParameters, TimeRange timeRange, int batchSize, MoreSearch.ScrollCallback resultCallback) throws EventProcessorException This scrolls results for the given query, streams and time range from Elasticsearch. The result is passed to the given callback in batches. (using the given batch size)The search will continue until it is done, an error occurs or the search is stopped by setting the
TODO: Elasticsearch has a default limit of 500 concurrent scrolls. Every caller of this method should check if there is capacity to create a new scroll request. This can be done by using the ES nodes stats API. See: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#scroll-search-contextcontinueScrolling
boolean tofalse
from theMoreSearch.ScrollCallback
.- Parameters:
queryString
- the search query stringstreams
- the set of streams to search intimeRange
- the time range for the searchbatchSize
- the number of documents to retrieve at onceresultCallback
- the callback that gets executed for each batch- Throws:
EventProcessorException
-
loadStreams
-
luceneEscape
Helper to perform basic Lucene escaping of query string values- Parameters:
searchString
- search string which may contain unescaped reserved characters- Returns:
- String where those characters that Lucene expects to be escaped are escaped by a
preceding
\
-