You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-object-mapping.adoc
+45-8
Original file line number
Diff line number
Diff line change
@@ -58,21 +58,58 @@ Constructor arguments are mapped by name to the key values in the retrieved Docu
58
58
** `name`: The name of the field as it will be represented in the Elasticsearch document, if not set, the Java field name is used.
59
59
** `type`: The field type, can be one of _Text, Keyword, Long, Integer, Short, Byte, Double, Float, Half_Float, Scaled_Float, Date, Date_Nanos, Boolean, Binary, Integer_Range, Float_Range, Long_Range, Double_Range, Date_Range, Ip_Range, Object, Nested, Ip, TokenCount, Percolator, Flattened, Search_As_You_Type_.
60
60
See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html[Elasticsearch Mapping Types]
61
-
** `format`: One or more built-in formats, default value is _strict_date_optional_time_ and _epoch_millis_.
62
-
See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats[Elasticsearch Built In Formats]
63
-
** `pattern`: One or more custom date formats. NOTE: If you want to use only custom date formats, you must set the `format` property to empty `{}`.
64
-
See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#custom-date-formats[Elasticsearch Custom Date Formats]
61
+
** `format`: One or more built-in date formats, see the next section <<elasticsearch.mapping.meta-model.date-formats>>.
62
+
** `pattern`: One or more custom date formats, see the next section <<elasticsearch.mapping.meta-model.date-formats>>.
65
63
** `store`: Flag whether the original field value should be store in Elasticsearch, default value is _false_.
66
64
** `analyzer`, `searchAnalyzer`, `normalizer` for specifying custom analyzers and normalizer.
67
65
* `@GeoPoint`: Marks a field as _geo_point_ datatype.
68
66
Can be omitted if the field is an instance of the `GeoPoint` class.
69
67
70
-
NOTE: Properties that derive from `TemporalAccessor` or are of type `java.util.Date` must either have a `@Field` annotation of type `FieldType.Date`.
71
-
If you are using a custom date format, you need to use _uuuu_ for the year instead of _yyyy_.
72
-
This is due to a https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-to-java-time.html#java-time-migration-incompatible-date-formats[change in Elasticsearch 7].
73
-
74
68
The mapping metadata infrastructure is defined in a separate spring-data-commons project that is technology agnostic.
75
69
70
+
[[elasticsearch.mapping.meta-model.date-formats]]
71
+
==== Date format mapping
72
+
73
+
Properties that derive from `TemporalAccessor` or are of type `java.util.Date` must either have a `@Field` annotation
74
+
of type `FieldType.Date` or a custom converter must be registered for this type. This paragraph describes the use of
75
+
`FieldType.Date`.
76
+
77
+
There are two attributes of the `@Field` annotation that define which date format information is written to the
78
+
mapping (also see https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats[Elasticsearch Built In Formats] and https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#custom-date-formats[Elasticsearch Custom Date Formats])
79
+
80
+
The `format` attributes is used to define at least one of the predefined formats. If it is not defined, then a
81
+
default value of __date_optional_time_ and _epoch_millis_ is used.
82
+
83
+
The `pattern` attribute can be used to add additional custom format strings. If you want to use only custom date formats, you must set the `format` property to empty `{}`.
84
+
85
+
The following table shows the different attributes and the mapping created from their values:
NOTE: If you are using a custom date format, you need to use _uuuu_ for the year instead of _yyyy_.
111
+
This is due to a https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-to-java-time.html#java-time-migration-incompatible-date-formats[change in Elasticsearch 7].
112
+
76
113
==== Mapped field names
77
114
78
115
Without further configuration, Spring Data Elasticsearch will use the property name of an object as field name in Elasticsearch. This can be changed for individual field by using the `@Field` annotation on that property.
Copy file name to clipboardExpand all lines: src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java
0 commit comments