use of org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString 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);
}
use of org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString in project graylog2-server by Graylog2.
the class AggregationEventProcessor method groupByQueryString.
// Return the ES query string for the group by fields specified in event; or empty if none specified.
// Search value is escaped and enclosed in quotes.
private ElasticsearchQueryString groupByQueryString(Event event) {
ElasticsearchQueryString result = ElasticsearchQueryString.empty();
if (!config.groupBy().isEmpty()) {
for (String key : event.getGroupByFields().keySet()) {
String value = event.getGroupByFields().get(key);
String query = new StringBuilder(key).append(":\"").append(luceneEscape(value)).append("\"").toString();
result = result.concatenate(ElasticsearchQueryString.of(query));
}
}
return result;
}
Aggregations