Thursday, October 1, 2015

Set a `java.util.Date` typed field as `date` type in Elasticsearch

To set a `java.util.Date` typed field as `date` type in Elasticsearch,

use `@Field` as follows:

  @Field(type = FieldType.Date)
  private Date timestamp;

and check as follows:

curl -XGET 'http://localhost:9200/event/_mapping?pretty'

and then you will see as follows:

          "timestamp" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          }

No comments:

Post a Comment