当前位置:网站首页>ES:Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
ES:Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
2022-07-26 16:15:00 【此方星河】
发生缘由
- 学习ES中Java HighLevel Rest Client客户端API
运行环境
- elasticsearch版本:7.12.1
- jdk版本:jdk-8
- 电脑系统:win10
- Idea版本:2021.2
报错信息
org.elasticsearch.common.compress.NotXContentException: Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
at org.elasticsearch.common.compress.CompressorFactory.compressor(CompressorFactory.java:42)
at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(XContentHelper.java:108)
at org.elasticsearch.client.indices.CreateIndexRequest.source(CreateIndexRequest.java:276)
at org.elasticsearch.client.indices.CreateIndexRequest.source(CreateIndexRequest.java:257)
at com.linxuan.hotel.HotelDemoApplicationTests.createHotelIndex(HotelDemoApplicationTests.java:33)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at java.util.ArrayList.forEach(ArrayList.java:1249)
分析排查
- Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes
- 压缩器检测只能在某些 xcontent 字节或压缩的 xcontent 字节上面调用
根据报错原因可以将错误定位至HotelDemoApplicationTests.java:33行,代码如下:
@Test
void createHotelIndex() throws IOException {
// 1.创建Request对象
CreateIndexRequest request = new CreateIndexRequest("hotel");
// 2.准备请求的参数 DSL语句
// 33行 报错
request.source(MAPPING_TEMPLATE, XContentType.JSON);
// 3.发送请求
client.indices().create(request, RequestOptions.DEFAULT);
}
那么就可以将报错信息转为人话了:语句的类型不是JSON风格的或者JSON格式化错误了。
定位MAPPING_TEMPLATE,代码如下:
public static final String MAPPING_TEMPLATE = "PUT /hotel\n" +
"{\n" +
" \"mappings\": {\n" +
" \"properties\": {\n" +
" \"id\": {\n" +
" \"type\": \"keyword\"\n" +
" },\n" +
" \"name\":{\n" +
" \"type\": \"text\",\n" +
" \"analyzer\": \"ik_max_word\",\n" +
" \"copy_to\": \"all\"\n" +
" },\n" +
" \"address\":{\n" +
" \"type\": \"keyword\",\n" +
" \"index\": false\n" +
" },\n" +
" \"all\":{\n" +
" \"type\": \"text\",\n" +
" \"analyzer\": \"ik_max_word\"\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n";
OK,原因找到了,因为添加了这一点代码:"PUT /hotel\n" +。将其删去即可。
边栏推荐
- The difference and efficiency comparison of three methods of C # conversion integer
- 技术风向标 | 云原生技术架构成熟度模型解读
- Clojure 运行原理之编译器剖析
- TDengine 落地协鑫能科,数百亿数据压缩至 600GB
- Build resume editor based on Nocode
- 博途PLC顺序开关机功能块(SCL)
- 结构体和类使用的区别
- Pat class a 1047 student list for course
- Sword finger offer special assault edition day 11
- Bugku login1
猜你喜欢

ACL-IJCAI-SIGIR顶级会议论文报告会(AIS 2022)笔记3:对话和生成

Nacos win10 安装配置教程

docker安装redis?如何配置持久化策略?

Bugku login1

Re8:读论文 Hier-SPCNet: A Legal Statute Hierarchy-based Heterogeneous Network for Computing Legal Case

Application of workflow engine in vivo marketing automation

Linux安装mysql8.0.29详细教程
![[fluent -- advanced] packaging](/img/aa/bd6ecad52cbe4a34db75f067aa4dfe.png)
[fluent -- advanced] packaging

Differences between the use of structs and classes

2022 test questions and answers for the latest national fire facility operator (senior fire facility operator)
随机推荐
A firefox/chrome plug-in that visualizes browser history
最终一致性性分布式事务 TCC
综合设计一个OPPE主页--布局与初始化
Pat grade a 1049 counting ones
The difference and efficiency comparison of three methods of C # conversion integer
First knowledge of OpenGL (3) fragment shader
JVM 的类初始化机制
综合设计一个OPPE主页--顶部,头部的设计
kubernetes之探针
《硅谷之谜》读后感
Bugku login2
Pat grade a 1046 shortest distance
What is GPIO and what is its use
【E-MR】NameNode的错误恢复记录
【物理模拟】最简单的shape matching的原理与实践
2022 latest Tibet Construction scaffolder (construction special operation) simulation exam questions and answers
PAT甲级 1046 Shortest Distance
匿名方法和lambda表达式使用的区别
[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)
Comprehensively design an oppe homepage -- the design of the top and head