Query profiling
When you are executing queries, sometimes, they are not as fast as you think. The reasons why some queries need a lot of time to be executed vary, but using tools to profile them can solve your issues more quickly.
This feature is available from Elasticsearch 5.x, or greater, via the profile API. It allows the user to track the time spent by Elasticsearch in executing a search or an aggregation.
Note
This is only a debug tool because of the significant overhead involved in its execution: for each Lucene step, it computes the part of scores, which takes a significant amount of time during query execution.
Getting ready
You will need an up-and-running Elasticsearch installation, as described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute these commands, any HTTP client can be used, such as Curl (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or similar. I suggest...