Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How track json request sent to Elasticsearch via elastic4s client?

Say that I use such code:

ElasticClient client = ...
client.execute{search in "places"->"cities" query "paris" start 5 limit 10}

How to see what json request was been sent to Elasticsearch?

like image 245
Cherry Avatar asked Dec 24 '22 18:12

Cherry


1 Answers

In Elastic4s 1.6.2 you can use the show typeclass on a number of requests to get the JSON equivilent.

It's pretty straightforward.

val req = search in "index" / "type" query "kate bush"
logger.debug(s"Search request ${req.show}")

The .show method will render JSON output. It works on most of the request types.

In Elastic4s 5.2.0+, you use the show method on the client.

val req = search("index" / "type").query("kate bush")
client.show(req)
like image 190
sksamuel Avatar answered Dec 27 '22 11:12

sksamuel