use of com.netflix.conductor.elasticsearch.query.parser.ParserException in project conductor by Netflix.
the class ElasticSearchDAOV6 method search.
private SearchResult<String> search(String structuredQuery, int start, int size, List<String> sortOptions, String freeTextQuery, String docType) {
try {
docType = StringUtils.isBlank(docTypeOverride) ? docType : docTypeOverride;
BoolQueryBuilder fq = boolQueryBuilder(structuredQuery, freeTextQuery);
final SearchRequestBuilder srb = elasticSearchClient.prepareSearch(getIndexName(docType)).setQuery(fq).setTypes(docType).storedFields("_id").setFrom(start).setSize(size);
addSortOptions(srb, sortOptions);
return mapSearchResult(srb.get());
} catch (ParserException e) {
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, e.getMessage(), e);
}
}
use of com.netflix.conductor.elasticsearch.query.parser.ParserException in project conductor by Netflix.
the class ElasticSearchDAOV5 method search.
private SearchResult<String> search(String indexName, String structuredQuery, int start, int size, List<String> sortOptions, String freeTextQuery, String docType) {
try {
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);
if (sortOptions != null) {
sortOptions.forEach(sortOption -> addSortOptionToSearchRequest(srb, sortOption));
}
SearchResponse response = srb.get();
LinkedList<String> result = StreamSupport.stream(response.getHits().spliterator(), false).map(SearchHit::getId).collect(Collectors.toCollection(LinkedList::new));
long count = response.getHits().getTotalHits();
return new SearchResult<>(count, result);
} catch (ParserException e) {
String errorMsg = String.format("Error performing search on index:%s with docType:%s", indexName, docType);
logger.error(errorMsg);
throw new ApplicationException(Code.BACKEND_ERROR, errorMsg, e);
}
}
Aggregations