在elasticsearch-rails中输出详细日志

使用elasticsearch-rails与elasticsearch进行交互时,如何查看详细的通信日志。
通过传递log: true, trace: true选项即可。

Elasticsearch::Client.new(hosts: 'localhost:9999', log: true, trace: true)

请提供请求和响应的JSON以及相应的curl命令。

2023-06-23 00:00:00 +0900: > {"query":{"bool":{"filter":[{"terms":{"id":[999]}}]}},"sort":{"id":"desc"},"size":100,"from":0,"track_total_hits":true,"_source":["id"]}
2023-06-23 00:00:00 +0900: < {"took":6,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":0,"relation":"eq"},"max_score":null,"hits":[]}}

curl -X POST -H 'x-elastic-client-meta: es=7.13.3,rb=2.7.0,t=7.13.3,fd=1.10.2,hc=2.8.3, User-Agent: elasticsearch-ruby/7.13.3 (RUBY_VERSION: 2.7.0; linux aarch64; Faraday v1.10.2), Content-Type: application/json' 'http://localhost:9999/applications/_search?pretty' -d '{
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "id": [
              999
            ]
          }
        }
      ]
    }
  },
  "sort": {
    "id": "desc"
  },
  "size": 100,
  "from": 0,
  "track_total_hits": true,
  "_source": [
    "id"
  ]
}'
广告
将在 10 秒后关闭
bannerAds