elastic search 5.4.版本,java api 调用出现:can not write type [class java.math.BigDecimal]
Elasticsearch | 作者 wangxuanmail | 发布于2018年03月21日 | 阅读数:11571
{
"from" : 0,
"size" : 20,
"timeout" : "999ms",
"query" : {
"bool" : {
"must" : [
{
"match_all" : {
"boost" : 1.0
}
}
],
"filter" : [
{
"term" : {
"air_displacement" : {
"value" : "1.6",
"boost" : 1.0
}
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"_source" : {
"includes" : [
"product_id"
],
"excludes" : [ ]
},
"sort" : [
{
"allow_sale" : {
"order" : "desc"
}
}
],
"track_scores" : true
}
这个请求在kibana 直接查询没有问题,但是调用java api 后 api报错,mapping设置该字段为float,
UncategorizedExecutionException[Failed execution]; nested: IOException[can not write type [class java.math.BigDecimal]];
at org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:89)
at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:47)
at com.guazi.search.query.retriever.BasicRetriever.query(BasicRetriever.java:61)
at com.guazi.search.query.service.thrift.impl.QueryHandler$1Dummy.call(QueryHandler.java:278)
at com.guazi.search.query.service.thrift.impl.QueryHandler$1Dummy.call(QueryHandler.java:275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.util.concurrent.SimpleTimeLimiter$1$1.call(SimpleTimeLimiter.java:104)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: can not write type [class java.math.BigDecimal]
at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:655)
at org.elasticsearch.index.query.BaseTermQueryBuilder.doWriteTo(BaseTermQueryBuilder.java:134)
at org.elasticsearch.index.query.AbstractQueryBuilder.writeTo(AbstractQueryBuilder.java:72)
at org.elasticsearch.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:857)
at org.elasticsearch.index.query.AbstractQueryBuilder.writeQueries(AbstractQueryBuilder.java:248)
at org.elasticsearch.index.query.BoolQueryBuilder.doWriteTo(BoolQueryBuilder.java:102)
at org.elasticsearch.index.query.AbstractQueryBuilder.writeTo(AbstractQueryBuilder.java:72)
at org.elasticsearch.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:857)
at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalNamedWriteable(StreamOutput.java:868)
at org.elasticsearch.search.builder.SearchSourceBuilder.writeTo(SearchSourceBuilder.java:240)
at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalWriteable(StreamOutput.java:732)
at org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:361)
at org.elasticsearch.transport.TcpTransport.buildMessage(TcpTransport.java:1219)
at org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:1071)
at org.elasticsearch.transport.TcpTransport.access$1100(TcpTransport.java:116)
at org.elasticsearch.transport.TcpTransport$NodeChannels.sendRequest(TcpTransport.java:446)
at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:569)
at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:502)
at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:490)
at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51)
at org.elasticsearch.client.transport.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:251)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
... 12 more
es2.2 java api就没有这个问题。目前发现只有es 5.4这个版本有问题。哪位大神之前遇到过这个问题。有什么办法可以解决
"from" : 0,
"size" : 20,
"timeout" : "999ms",
"query" : {
"bool" : {
"must" : [
{
"match_all" : {
"boost" : 1.0
}
}
],
"filter" : [
{
"term" : {
"air_displacement" : {
"value" : "1.6",
"boost" : 1.0
}
}
}
],
"disable_coord" : false,
"adjust_pure_negative" : true,
"boost" : 1.0
}
},
"_source" : {
"includes" : [
"product_id"
],
"excludes" : [ ]
},
"sort" : [
{
"allow_sale" : {
"order" : "desc"
}
}
],
"track_scores" : true
}
这个请求在kibana 直接查询没有问题,但是调用java api 后 api报错,mapping设置该字段为float,
UncategorizedExecutionException[Failed execution]; nested: IOException[can not write type [class java.math.BigDecimal]];
at org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:89)
at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:47)
at com.guazi.search.query.retriever.BasicRetriever.query(BasicRetriever.java:61)
at com.guazi.search.query.service.thrift.impl.QueryHandler$1Dummy.call(QueryHandler.java:278)
at com.guazi.search.query.service.thrift.impl.QueryHandler$1Dummy.call(QueryHandler.java:275)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.common.util.concurrent.SimpleTimeLimiter$1$1.call(SimpleTimeLimiter.java:104)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: can not write type [class java.math.BigDecimal]
at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:655)
at org.elasticsearch.index.query.BaseTermQueryBuilder.doWriteTo(BaseTermQueryBuilder.java:134)
at org.elasticsearch.index.query.AbstractQueryBuilder.writeTo(AbstractQueryBuilder.java:72)
at org.elasticsearch.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:857)
at org.elasticsearch.index.query.AbstractQueryBuilder.writeQueries(AbstractQueryBuilder.java:248)
at org.elasticsearch.index.query.BoolQueryBuilder.doWriteTo(BoolQueryBuilder.java:102)
at org.elasticsearch.index.query.AbstractQueryBuilder.writeTo(AbstractQueryBuilder.java:72)
at org.elasticsearch.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:857)
at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalNamedWriteable(StreamOutput.java:868)
at org.elasticsearch.search.builder.SearchSourceBuilder.writeTo(SearchSourceBuilder.java:240)
at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalWriteable(StreamOutput.java:732)
at org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:361)
at org.elasticsearch.transport.TcpTransport.buildMessage(TcpTransport.java:1219)
at org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:1071)
at org.elasticsearch.transport.TcpTransport.access$1100(TcpTransport.java:116)
at org.elasticsearch.transport.TcpTransport$NodeChannels.sendRequest(TcpTransport.java:446)
at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:569)
at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:502)
at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:490)
at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51)
at org.elasticsearch.client.transport.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:251)
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
... 12 more
es2.2 java api就没有这个问题。目前发现只有es 5.4这个版本有问题。哪位大神之前遇到过这个问题。有什么办法可以解决
3 个回复
kennywu76 - Wood
赞同来自: xiaoxiao
所以数据类型的定义上,需要使用ES支持的类型。
wangxuanmail
赞同来自:
hnj1575565068 - 90后
赞同来自: