use of org.graylog.plugins.views.search.ParameterProvider in project graylog2-server by Graylog2.
the class QueryValidationServiceImpl method decoratedQuery.
private String decoratedQuery(ValidationRequest req) {
ParameterProvider parameterProvider = (name) -> req.parameters().stream().filter(p -> Objects.equals(p.name(), name)).findFirst();
final Query query = Query.builder().query(req.query()).timerange(req.timerange()).build();
return this.queryStringDecorators.decorate(req.getCombinedQueryWithFilter(), parameterProvider, query);
}
use of org.graylog.plugins.views.search.ParameterProvider in project graylog2-server by Graylog2.
the class ESMessageListTest method appliesDecoratorsToQueryStringIfHighlightingActivated.
@Test
public void appliesDecoratorsToQueryStringIfHighlightingActivated() {
final QueryStringDecorator queryStringDecorator = (String queryString, ParameterProvider job, Query query) -> "Foobar!";
final MessageList messageList = someMessageList();
ESGeneratedQueryContext queryContext = generateQueryPartWithHighlighting(messageList, Collections.singleton(queryStringDecorator));
final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
JsonPathAssert.assertThat(doc).jsonPathAsString("$.highlight.highlight_query.query_string.query").isEqualTo("Foobar!");
}
use of org.graylog.plugins.views.search.ParameterProvider in project graylog2-server by Graylog2.
the class ESMessageListTest method appliesDecoratorsToQueryStringIfHighlightingActivated.
@Test
public void appliesDecoratorsToQueryStringIfHighlightingActivated() {
final QueryStringDecorator queryStringDecorator = (String queryString, ParameterProvider job, Query query) -> "Foobar!";
final MessageList messageList = someMessageList();
ESGeneratedQueryContext queryContext = generateQueryPartWithHighlighting(messageList, Collections.singleton(queryStringDecorator));
final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
JsonPathAssert.assertThat(doc).jsonPathAsString("$.highlight.highlight_query.query_string.query").isEqualTo("Foobar!");
}
Aggregations