ElasticSearch使用过程中的常用问题
ES版本号7.1.0 Transport 7.1.0
依赖参考地址:https://mvnrepository.com/
ElasticSearch常用问题:
1:
{
"error" : "Content-Type header [application/x-www-form-urlencoded] is not supported",
"status" : 406
}
原因:es6.0之后官方部分调整
curl -H "Content-Type: application/json" -X POST
加上 -H "Content-Type: application/json"
2、
解决办法:引入依赖
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>7.1.0</version>
</dependency>
如果加了后报这个错误:
java.lang.NoSuchMethodError: io.netty.util.AttributeKey.newInstance(Ljava/lang/String;)Lio/netty/util/AttributeKey;
那么遗憾的是,你也入坑了。此处是你的project中netty的版本冲突,可以通过mvn 命令了解冲突包,但是不建议采用,因为那个对于依赖多的project的话会看花眼的,推荐使用maven helper 插件。移除冲突的包即可。
3、
Rejecting mapping update to [XXX] as the final mapping would have more than 1 type: [XXX, XX]"
6.0的版本不允许一个index下面有多个type