当前位置:网站首页>Es time query error - "caused_by": {"type": "illegal_argument_exception", "reason": "failed to parse date field
Es time query error - "caused_by": {"type": "illegal_argument_exception", "reason": "failed to parse date field
2022-07-27 05:46:00 【Code world of super Duoduo and Liu baobao】
Project scenario :
stay ES In the course of using , The query function of time range is used , The error message with time resolution error :“caused_by”:{“type”:“illegal_argument_exception”,“reason”:"failed to parse date field …
Problem description
Inquire about query Object part field description
@ApiModelProperty(value = " Starting time ")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
private Date searchStartTime;
@ApiModelProperty(value = " End time ")
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
private Date searchEndTime;
Query time range error java Code
// Time range
if (query.getSearchStartTime()!=null && query.getSearchEndTime()!=null){
RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("createTime");
rangeQuery.from(query.getSearchStartTime());
rangeQuery.to(query.getSearchEndTime());
// because filter Than query fast , Can also be rangeQuery Put in sourceBuilder
boolQueryBuilder.filter(rangeQuery);
}
Error message
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://192.168.9.194:9200], URI [/upload-file/_search?pre_filter_shard_size=128&typed_keys=true&max_cothrottled=true&search_type=query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true], status line [HTTP/1.1 400 Bad Request]
{
"error":{
"root_cause":
[{
"type":"parse_exception",
"reason":"failed to parse date field [2022-02-28T16:00:00.000Z] with format [yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:m-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis]]"}],
"type":"search_phase_execution_exception",
"reason":"all shards failed",
"phase":"query",
"grouped"e_exception",
"reason":"failed to parse date field [2022-02-28T16:00:00.000Z] with format [yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis]: [f/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis]]",
"caused_by":{
"type":"illegal_argument_exception",
"reason":"failed to parse date field [2022-02-28T16:00:00.000Z] with format [yyyy-MM-darse_exception","reason":"Failed to parse with all enclosed parsers"}}}}]},"status":400}
Cause analysis :
es and mysql Different ,mysql Pass in date After parsing, it can be directly used as a parameter sql spell , however es I don't think so , Need to be converted to timestamp
Solution :
Turn the time parameter into timestamp for query
// Time range
if (query.getSearchStartTime()!=null && query.getSearchEndTime()!=null){
RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("createTime");
rangeQuery.from(query.getSearchStartTime().getTime());
rangeQuery.to(query.getSearchEndTime().getTime());
// because filter Than query fast , Can also be rangeQuery Put in sourceBuilder
boolQueryBuilder.filter(rangeQuery);
}
Suggest
I tried localdatetime Type of time , But no date Type is easy to use
边栏推荐
- 怎么开立普通商品期货账户
- 期货开户之前要先谈好手续费
- [极客大挑战 2019]FinalSQL 1
- 1024 | 正式称为码农的第四年,初心犹在,继续前进
- 原油期货开户条件和流程是什么?
- Arguments class array in JS
- Face brushing payment is more in line with Alipay's concept of always being ecological
- SeekTiger的Okaleido有大动作,生态通证STI会借此爆发?
- 刷脸支付用户主要优势是智能化程度高
- Personal collection code cannot be used for business collection
猜你喜欢

Mysql5.7版本如何实现主从同步

使用Docker部署Redis进行高可用主从复制

NFT新范式,OKALEIDO创新NFT聚合交易生态

kettle的文件名通配规则

You can't even do a simple function test well. What do you take to talk about salary increase with me?

Personal collection code cannot be used for business collection

Basic layout of the page

Several ways of element positioning in page layout

How can I get the lowest handling charge for opening a futures account?

GameFi如何破圈,AQUANEE靠真正“P2E”展现风采
随机推荐
DeFi 2.0的LaaS协议Elephant,或许是你熊市下为数不多的获利手段
In the future, face brushing payment can occupy a lot of market share
NFT市场格局仍未变化,Okaleido能否掀起新一轮波澜?
graph-node部署
Getaverse,走向Web3的远方桥梁
Department management of cloud e-office projects
MOVE PROTOCOL推出测试版,更可“0撸”参与P2E
Minio分片上传解除分片大小限制 - chunk size must be greater than 5242880
Configure the route and go to the login home page to send the request
Dimitra 和 Ocean Protocol 解读农业数据背后的秘密
What are Dom and BOM in JS
[极客大挑战 2019]FinalSQL 1
What is the difference between foreach and map methods in JS
攻防世界-mfw
Self understanding and thinking
Common interview questions in software testing
攻防世界-lottery
记一次PG主从搭建及数据同步性能测试流程
Sequel Pro下载及使用方法
How can I get the lowest handling charge for opening a futures account?