本文介绍了如何通过elastic4s客户端将json请求发送到Elasticsearch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我使用这样的代码:

  ElasticClient client = ... 
client.execute {search in places - >cities查询parisstart 5 limit 10}

如何看什么json请求被发送到Elasticsearch?

解决方案

在Elastic4s 1.6.2中,您可以使用的许多请求,以获得JSON等同。



这很简单。

  val req =在索引/类型查询中搜索kate bush
logger.debug 搜索请求$ {req.show})

.show 方法将渲染JSON输出。它适用于大多数请求类型。



在Elastic4s 5.2.0+中,您可以使用 show 方法客户端。

  val req = search(index/type)。query(kate bush)
client.show(req)


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?

解决方案

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)

这篇关于如何通过elastic4s客户端将json请求发送到Elasticsearch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 00:32