opensearch-java icon indicating copy to clipboard operation
opensearch-java copied to clipboard

[FEATURE] serialize requests to JSON

Open dblock opened this issue 2 years ago • 1 comments

Is your feature request related to a problem?

Add a way to easily serialize queries to JSON for logging.

What solution would you like?

            IndexRequest<Movie> indexRequest = new IndexRequest.Builder<Movie>()
                    .index(index)
                    .id("1")
                    .document(movie)
                    .build();

            logger.info("JSON: {}", indexRequest.toJson());

Working serialization code here.

Do you have any additional context?

From a Slack discussion in https://opensearch.slack.com/archives/C051XNH62KB/p1690396113772759

dblock avatar Jul 31 '23 16:07 dblock

Sounds cool. I've seen a few people request this, and it's cleaner than using log4j.

wbeckler avatar Aug 02 '23 16:08 wbeckler