public ParsedQuery parse(QueryBuilder queryBuilder) throws ElasticSearchException {
XContentParser parser = null;
try {
BytesStream unsafeBytes = queryBuilder.buildAsUnsafeBytes();
parser = XContentFactory.xContent(unsafeBytes.unsafeByteArray(), 0, unsafeBytes.size()).createParser(unsafeBytes.unsafeByteArray(), 0, unsafeBytes.size());
return parse(cache.get(), parser);
} catch (QueryParsingException e) {
throw e;
} catch (Exception e) {
throw new QueryParsingException(index, "Failed to parse", e);