Elasticsearch cannot write xcontent for unknown value of type class java.sql.Timestamp

Elasticsearch cannot write xcontent for unknown value of type class java.sql.Timestamp

在使用Elasticsearch进行index数据时,发现报错如下:

java.lang.IllegalArgumentException: cannot write xcontent for unknown value of type class java.math.Timestamp
	at org.elasticsearch.common.xcontent.XContentBuilder.unknownValue(XContentBuilder.java:755)
	at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:726)
	at org.elasticsearch.common.xcontent.XContentBuilder.field(XContentBuilder.java:711)
	at org.elasticsearch.index.query.BaseTermQueryBuilder.doXContent(BaseTermQueryBuilder.java:154)
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:82)
	at org.elasticsearch.index.query.BoolQueryBuilder.doXArrayContent(BoolQueryBuilder.java:275)
	at org.elasticsearch.index.query.BoolQueryBuilder.doXContent(BoolQueryBuilder.java:256)
	at org.elasticsearch.index.query.AbstractQueryBuilder.toXContent(AbstractQueryBuilder.java:82)
	at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:779)
	at org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:772)
	at org.elasticsearch.common.xcontent.XContentBuilder.field(XContentBuilder.java:764)
	at org.elasticsearch.search.builder.SearchSourceBuilder.toXContent(SearchSourceBuilder.java:1184)
	at org.elasticsearch.common.xcontent.XContentHelper.toXContent(XContentHelper.java:349)
	at org.elasticsearch.search.builder.SearchSourceBuilder.toString(SearchSourceBuilder.java:1558)
	at org.elasticsearch.search.builder.SearchSourceBuilder.toString(SearchSourceBuilder.java:1553)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at org.elasticsearch.action.search.SearchRequest.toString(SearchRequest.java:516)

以上此类问题找不到对应的数据类型type

从异常信息看,显然ES无法接受Timestamp类型,本文使用es版本未6.3.2,目前的解决办法是:转换别的es支持的数据类型。

参考:ELK系列(4) – Elasticsearch cannot write xcontent for unknown value of type class java.math.BigDecimal

参考:[elastic search 5.4.版本,java api 调用出现:can not write type [class java.math.BigDecimal]](

Elasticsearch cannot write xcontent for unknown value of type class java.sql.TimestampElasticsearch cannot write xcontent for unknown value of type class java.sql.Timestamp JDZW2010 发布了69 篇原创文章 · 获赞 6 · 访问量 2万+ 私信 关注
上一篇:LifecyclePhaseNotFoundException,Unknown lifecycle phase "mvn". You must specify a valid


下一篇:配置 git公钥报错:unknown key type -rsa