use of com.netflix.conductor.dao.es6.index.query.parser.Expression in project conductor by Netflix.
the class ElasticSearchRestDAOV5 method getTaskExecutionLogs.
@Override
public List<TaskExecLog> getTaskExecutionLogs(String taskId) {
try {
// Build Query
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);
// Create the searchObjectIdsViaExpression source
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(fq);
searchSourceBuilder.sort(new FieldSortBuilder("createdTime").order(SortOrder.ASC));
searchSourceBuilder.size(config.getElasticSearchTasklogLimit());
// Generate the actual request to send to ES.
SearchRequest searchRequest = new SearchRequest(logIndexPrefix + "*");
searchRequest.types(LOG_DOC_TYPE);
searchRequest.source(searchSourceBuilder);
SearchResponse response = elasticSearchClient.search(searchRequest);
SearchHit[] hits = response.getHits().getHits();
List<TaskExecLog> logs = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
String source = hit.getSourceAsString();
TaskExecLog tel = objectMapper.readValue(source, TaskExecLog.class);
logs.add(tel);
}
return logs;
} catch (Exception e) {
logger.error("Failed to get task execution logs for task: {}", taskId, e);
}
return null;
}
use of com.netflix.conductor.dao.es6.index.query.parser.Expression in project conductor by Netflix.
the class ElasticSearchRestDAOV5 method searchObjectIdsViaExpression.
private SearchResult<String> searchObjectIdsViaExpression(String structuredQuery, int start, int size, List<String> sortOptions, String freeTextQuery, String docType) {
try {
// Build query
QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
if (StringUtils.isNotEmpty(structuredQuery)) {
Expression expression = Expression.fromString(structuredQuery);
queryBuilder = expression.getFilterBuilder();
}
BoolQueryBuilder filterQuery = QueryBuilders.boolQuery().must(queryBuilder);
QueryStringQueryBuilder stringQuery = QueryBuilders.queryStringQuery(freeTextQuery);
BoolQueryBuilder fq = QueryBuilders.boolQuery().must(stringQuery).must(filterQuery);
return searchObjectIds(indexName, fq, start, size, sortOptions, docType);
} catch (Exception e) {
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, e.getMessage(), e);
}
}
use of com.netflix.conductor.dao.es6.index.query.parser.Expression in project conductor by Netflix.
the class ElasticSearchRestDAOV5 method getEventExecutions.
@Override
public List<EventExecution> getEventExecutions(String event) {
try {
Expression expression = Expression.fromString("event='" + event + "'");
QueryBuilder queryBuilder = expression.getFilterBuilder();
BoolQueryBuilder filterQuery = QueryBuilders.boolQuery().must(queryBuilder);
QueryStringQueryBuilder stringQuery = QueryBuilders.queryStringQuery("*");
BoolQueryBuilder query = QueryBuilders.boolQuery().must(stringQuery).must(filterQuery);
// Create the searchObjectIdsViaExpression source
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(query);
searchSourceBuilder.sort(new FieldSortBuilder("created").order(SortOrder.ASC));
// Generate the actual request to send to ES.
SearchRequest searchRequest = new SearchRequest(logIndexPrefix + "*");
searchRequest.types(EVENT_DOC_TYPE);
searchRequest.source(searchSourceBuilder);
SearchResponse response = elasticSearchClient.search(searchRequest);
return mapEventExecutionsResponse(response);
} catch (Exception e) {
logger.error("Failed to get executions for event: {}", event, e);
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, e.getMessage(), e);
}
}
use of com.netflix.conductor.dao.es6.index.query.parser.Expression in project conductor by Netflix.
the class TestElasticSearchRestDAOV5 method searchObjectIdsViaExpression.
private SearchResponse searchObjectIdsViaExpression(String indexName, String structuredQuery, int start, int size, List<String> sortOptions, String freeTextQuery, String docType) throws ParserException, IOException {
// Build query
QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
if (StringUtils.isNotEmpty(structuredQuery)) {
Expression expression = Expression.fromString(structuredQuery);
queryBuilder = expression.getFilterBuilder();
}
BoolQueryBuilder filterQuery = QueryBuilders.boolQuery().must(queryBuilder);
QueryStringQueryBuilder stringQuery = QueryBuilders.queryStringQuery(freeTextQuery);
BoolQueryBuilder fq = QueryBuilders.boolQuery().must(stringQuery).must(filterQuery);
return searchObjectIds(indexName, fq, start, size, sortOptions, docType);
}
use of com.netflix.conductor.dao.es6.index.query.parser.Expression in project conductor by Netflix.
the class TestElasticSearchDAOV5 method search.
private SearchResponse search(String indexName, String structuredQuery, int start, int size, String freeTextQuery, String docType) throws ParserException {
QueryBuilder queryBuilder = QueryBuilders.matchAllQuery();
if (StringUtils.isNotEmpty(structuredQuery)) {
Expression expression = Expression.fromString(structuredQuery);
queryBuilder = expression.getFilterBuilder();
}
BoolQueryBuilder filterQuery = QueryBuilders.boolQuery().must(queryBuilder);
QueryStringQueryBuilder stringQuery = QueryBuilders.queryStringQuery(freeTextQuery);
BoolQueryBuilder fq = QueryBuilders.boolQuery().must(stringQuery).must(filterQuery);
final SearchRequestBuilder srb = elasticSearchClient.prepareSearch(indexName).setQuery(fq).setTypes(docType).storedFields("_id").setFrom(start).setSize(size);
return srb.get();
}
Aggregations