elasticsearch - Elasticsearch-将Json字符串转换为XcontentBuilder

标签 elasticsearch

我使用的是Elasticsearch 6.2.2。这就是我将json字符串转换为Xcontentbuilder的方式。

XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint();
XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, jsonObj.toString());
builder.copyCurrentStructure(parser);

在更新Elasticsearch 6.3+之前,我一直工作良好。
使用相同代码的ES 6.3+出现错误。

Description Resource Path Location Type The method createParser(NamedXContentRegistry, DeprecationHandler, String) in the type JsonXContent is not applicable for the arguments (NamedXContentRegistry, String) test.java

最佳答案

编译错误已调出:您的createParser缺少DeprecationHandler 参数

因此,您应该设置DeprecationHandler,例如:

JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
                                      LoggingDeprecationHandler.INSTANCE, 
                                      jsonObj.toString());

关于elasticsearch - Elasticsearch-将Json字符串转换为XcontentBuilder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53386210/

相关文章:

java - 过滤logstash输入

elasticsearch - Elasticsearch:最近24小时(或时间段)内每种类型的新文档数量

elasticsearch - Elasticsearch 中的 BM25 相似度调整

algorithm - 不同ElasticSearch相似度算法的简单解释

regex - 如何在 Curator 过滤器上使用贪婪的正则表达式?

hadoop - 从配置单元到elasticsearch:

elasticsearch - 在Ubuntu上删除ElasticSearch

elasticsearch - 对可选字段不存在的Elasticsearch查询

elasticsearch - 在Elasticsearch中查询电子邮件ID时响应错误

c# - Elasticsearch NEST 5.0 中的 FilterContainer