简体   繁体   English

elasticsearch date_format 异常

[英]elasticsearch date_format exception

System Specs系统规格

Elasticsearch version 6.7.0 running in application
Elasticsearch version 6.3.2 running on docker container

POM looks like this below POM 如下所示

        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>6.7.0</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>6.70</version>
        </dependency>

Issue问题

I have a date field which uses the mapping below我有一个使用下面映射的日期字段

 "thisIsDate": {
      "type": "date",
      "format": "strict_date_time"
    }

The field is set up like in my application该字段的设置就像在我的应用程序中一样

 @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX", shape = JsonFormat.Shape.STRING, timezone = "UTC")
    public Instant thisIsDate;

And the data I am inserting into that field looks like this.我插入该字段的数据如下所示。

1900-10-22T12:34:56.78Z

But I keep getting back但我不断回来

"reason":"failed to parse date field with format [basic_date_time]"

I have used the following formats in the mapping but none of them fix my problem我在映射中使用了以下格式,但没有一个能解决我的问题

1. date_time 
2. basic_date_time 
3. strict_date_time
4. "yyyy-MM-dd'T'HH:mm:ss.SSSX"

Could someone point me in the right direction?有人能指出我正确的方向吗?

The issue is happening due to incompatible version of Elasticsearch server and Elasticsearch client.该问题是由于 Elasticsearch 服务器和 Elasticsearch 客户端版本不兼容而发生的。

As mentioned in every release there are some changed being introduced in the server which won't work if you don't upgrade your client version and that's the reason elasticsearch releases even client with every minor release like 7.4,7.5,7.6,7.7 if these could work without any issues then there was no need to do that.正如每个版本中提到的,如果您不升级客户端版本,服务器中将引入一些更改,这就是 elasticsearch 甚至在每个次要版本(如 7.4、7.5、7.6、7.7)中发布客户端的原因,如果这些可以毫无问题地工作,那么就没有必要这样做了。

This is a known issue and there are several StackOverflow posts related to various weird issues when Elasticsearch client doesn't match the server version.这是一个已知问题,当 Elasticsearch 客户端与服务器版本不匹配时,有几个 StackOverflow 帖子与各种奇怪的问题相关。

Best and neat solution is to make sure you use the same version of both server and client and update both of them simultaneously to avoid these weird issues.最好和简洁的解决方案是确保您使用相同版本的服务器和客户端并同时更新它们以避免这些奇怪的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM