use of org.eclipse.kapua.service.datastore.internal.elasticsearch.EsDatastoreException in project kapua by eclipse.
the class AbstractStorableQueryConverter method toSearchRequestBuilder.
public SearchRequestBuilder toSearchRequestBuilder(String indices, String type, Q query) throws KapuaException, EsDatastoreException, UnknownHostException {
if (query == null)
throw new EsDatastoreException(String.format("Query parameter is undefined"));
PredicateConverter pc = new PredicateConverter();
SearchRequestBuilder searchReqBuilder = EsClient.getcurrent().prepareSearch(indices);
searchReqBuilder.setTypes(type).setQuery(pc.toElasticsearchQuery(query.getPredicate())).setFrom(query.getOffset()).setSize(query.getLimit());
String[] includes = this.getIncludes(query.getFetchStyle());
String[] excludes = this.getExcludes(query.getFetchStyle());
if (includes != null || excludes != null)
searchReqBuilder.setFetchSource(includes, excludes);
if (this.getFields() != null && this.getFields().length > 0)
searchReqBuilder.addFields(this.getFields());
return searchReqBuilder;
}
use of org.eclipse.kapua.service.datastore.internal.elasticsearch.EsDatastoreException in project kapua by eclipse.
the class AbstractStorableQueryConverter method toCountRequestBuilder.
public SearchRequestBuilder toCountRequestBuilder(String indices, String type, Q query) throws KapuaException, EsDatastoreException, UnknownHostException {
if (query == null)
throw new EsDatastoreException(String.format("Query parameter is undefined"));
PredicateConverter pc = new PredicateConverter();
SearchRequestBuilder searchReqBuilder = EsClient.getcurrent().prepareSearch(indices);
searchReqBuilder.setTypes(type).setQuery(pc.toElasticsearchQuery(query.getPredicate())).setSize(0);
return searchReqBuilder;
}
Aggregations