如何在spring启动应用程序中显示elasticsearch查询

我正在弹簧启动应用程序中尝试弹性搜索,我想调试ElasticsearchRepository执行的查询.

试着
logging.level.org.elasticsearch.index.search.slowlog.query = INFO
spring.data.elasticsearch.properties.index.search.slowlog.threshold.query.info = 1毫秒
但我没有在日志中看到查询打印

最佳答案 在
Spring Boot 2中,您可以使用以下命令启用查询调试:

logging.level.org.springframework.data.elasticsearch.core=DEBUG

生成的日志将是这样的:

{
  "from" : 0,
  "size" : 10,
  "query" : {
    "bool" : {
      "must" : [
        {
          "query_string" : {
            "query" : "some string",
            "fields" : [
              "nome^1.0"
            ],
            "use_dis_max" : true,
            "tie_breaker" : 0.0,
            "default_operator" : "and",
            "auto_generate_phrase_queries" : false,
            "max_determinized_states" : 10000,
            "enable_position_increments" : true,
            "fuzziness" : "AUTO",
            "fuzzy_prefix_length" : 0,
            "fuzzy_max_expansions" : 50,
            "phrase_slop" : 0,
            "escape" : false,
            "split_on_whitespace" : true,
            "boost" : 1.0
          }
        }
      ],
      "disable_coord" : false,
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  },
  "version" : true
}

最好的祝福.

点赞