我正在尝试调试 ElasticSearch 查询。我已经为有问题的查询启用了解释,这表明查询正在做一个中间分数的乘积,它应该做一个总和。(我正在使用 elastic4s 创建查询请求。)
问题是我看不到生成的查询实际上是什么。我想确定 bug 是在 elastic4s 中(错误地生成查询请求)、在我的代码中还是在 elasticsearch 中。因此,我使用以下代码为测试中使用的嵌入式弹性搜索实例启用了日志记录:
ESLoggerFactory.setDefaultFactory(new Slf4jESLoggerFactory())
val settings = Settings.settingsBuilder
.put("path.data", dataDirPath)
.put("path.home", "/var/elastic/")
.put("cluster.name", clusterName)
.put("http.enabled", httpEnabled)
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
.put("discovery.zen.ping.multicast.enabled", false)
.put("index.refresh_interval", "10ms")
.put("script.engine.groovy.inline.search", true)
.put("script.engine.groovy.inline.update", true)
.put("script.engine.groovy.inline.mapping", true)
.put("index.search.slowlog.threshold.query.debug", "0s")
.put("index.search.slowlog.threshold.fetch.debug", "0s")
.build
但我在 logback.xml 中配置的日志文件中找不到任何查询。来自 elasticsearch 的其他日志消息出现在那里,而不是实际的查询。