looking at this example
client.execute{search in "places"->"cities" query "paris" start 5 limit 10}
is there an option to hook logging to client.execute to log all operations made by the client (index, search etc') ?
I saw this answer but I do not want to do something like :
val req = search in "index" / "type" query "kate bush"
logger.debug(s"Search request ${req.show}")
I want the client to log all base on the logging level
You can define your own ElasticClient, with overriding execute functionality
object MyElasticClientFactory {
def fromClient(client: Client): ElasticClient = new ElasticClient {
def close(): Unit = client.close()
def java: Client = client
override def execute[T, R, Q](request: T)(implicit executable: Executable[T, R, Q]): Future[Q] = {
// TODO your logging here
super.execute(request)
}
}
Take a look at TcpClient for reference https://github.com/sksamuel/elastic4s/blob/9a4074b6ff5616b648801352b4c3629cd0fc9020/elastic4s-tcp/src/main/scala/com/sksamuel/elastic4s/TcpClient.scala