I have the following code

    TermVectorsResponse resp = request.execute().actionGet();
    XContentBuilder builder = XContentFactory.jsonBuilder();
    resp.toXContent(builder, null);
    Map<String, Object> map = XContentHelper.convertToMap(builder.bytes(), false, XContentType.JSON).v2();
    return map;

and my compiler is complaining because it cannot resolve the method bytes() for XContentBuilder. My code worked for elasticsearch 6.2.2 and I know the error of the compiler is because in elasticsearch 7.5 the method bytes() was removed. So, how I’m I suppose to create the map variable, I’ve looked everywhere and I haven’t find an answer. I guess I’m supposed to create a JsonXContent and use it instead the builder.bytes() or retrieve the bytes another way but I don’t know for sure
Thanks in advance

the builder.bytes() is like a kind of anti pattern so you can get a BytesReference from your builder using:

BytesReference.bytes(builder)

example for 7.6:

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-put-stored-script.html