use of com.netflix.conductor.dao.es7.index.query.parser.Expression in project conductor by Netflix.
the class ElasticSearchDAOV5 method getTaskExecutionLogs.
@Override
public List<TaskExecLog> getTaskExecutionLogs(String taskId) {
try {
Expression expression = Expression.fromString("taskId='" + taskId + "'");
QueryBuilder queryBuilder = expression.getFilterBuilder();
BoolQueryBuilder filterQuery = QueryBuilders.boolQuery().must(queryBuilder);
QueryStringQueryBuilder stringQuery = QueryBuilders.queryStringQuery("*");
BoolQueryBuilder fq = QueryBuilders.boolQuery().must(stringQuery).must(filterQuery);
FieldSortBuilder sortBuilder = SortBuilders.fieldSort("createdTime").order(SortOrder.ASC);
final SearchRequestBuilder srb = elasticSearchClient.prepareSearch(logIndexPrefix + "*").setQuery(fq).setTypes(LOG_DOC_TYPE).addSort(sortBuilder).setSize(config.getElasticSearchTasklogLimit());
SearchResponse response = srb.execute().actionGet();
return Arrays.stream(response.getHits().getHits()).map(hit -> {
String source = hit.getSourceAsString();
try {
return objectMapper.readValue(source, TaskExecLog.class);
} catch (IOException e) {
logger.error("exception deserializing taskExecLog: {}", source);
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
} catch (Exception e) {
logger.error("Failed to get task execution logs for task: {}", taskId, e);
}
return null;
}
use of com.netflix.conductor.dao.es7.index.query.parser.Expression in project conductor by Netflix.
the class ElasticSearchBaseDAO method boolQueryBuilder.
BoolQueryBuilder boolQueryBuilder(String expression, String queryString) throws ParserException {
QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
if (StringUtils.isNotEmpty(expression)) {
Expression exp = Expression.fromString(expression);
queryBuilder = exp.getFilterBuilder();
}
BoolQueryBuilder filterQuery = QueryBuilders.boolQuery().must(queryBuilder);
QueryStringQueryBuilder stringQuery = QueryBuilders.queryStringQuery(queryString);
return QueryBuilders.boolQuery().must(stringQuery).must(filterQuery);
}
Aggregations