public void addQuery(String name, QueryBuilder queryBuilder) throws ElasticSearchException {
try {
XContentBuilder builder = XContentFactory.smileBuilder()
.startObject().field("query", queryBuilder).endObject();
BytesStream unsafeBytes = builder.unsafeStream();
addQuery(name, unsafeBytes.unsafeByteArray(), 0, unsafeBytes.size());
} catch (IOException e) {
throw new ElasticSearchException("Failed to add query [" + name + "]", e);
}
}