Reputation: 25725
I had a strange issue with elastic search when I had used the following annotation:
@Field(type = FieldType.Date, index = not_analyzed)
And attempted to insert dates with years such as 1000 using the spring elastic search JPA repository.
See: What are elastic searches max and min dates by default?
By changing the FieldType to String, it solved my problem and I did not get a weird error for extreme years.
What is the purpose of the FieldType enum and what do we use it for?
public enum FieldType {
String,
Integer,
Long,
Date,
Float,
Double,
Boolean,
Object,
Auto,
Nested,
Ip,
Attachment;
private FieldType() {
}
}
I read the documentation for elastic search and I don't really understand the use.
Upvotes: 1
Views: 397
Reputation: 1895
Elastic search supports multiple data-types, Spring FieldType holds enum for allowed ElasticSearch datatypes. It specify in which datatype should elastic search maps the value while storing.
For e.g.
@Field(type = FieldType.String, index = not_analyzed)
private String name;
Above code means ElasticSearch should store name field as 'text'
Upvotes: 1