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
Fix generics in ElasticsearchEntityMapper. Extract methods. Move enum conversion handling to simple type handling for symmetric implementation. Swap comparison of nullable types to avoid potential null dereference.
Rename ElasticsearchDefaultTypeMapper to DefaultElasticsearchTypeMapper. Move MapTypeAliasAccessor to DefaultElasticsearchTypeMapper.
Introduce SearchResultMapperAdapter to avoid empty method implementations in anonymous classes. Javadoc, reference docs, formatting.
Original Pull Request: spring-projects#237
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-object-mapping.adoc
+19-10Lines changed: 19 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -66,13 +66,26 @@ for `Converter` registration.
66
66
<3> Optionally set `CustomConversions` if applicable.
67
67
====
68
68
69
+
[[elasticsearch.mapping.meta-model.annotations]]
70
+
=== Mapping Annotation Overview
71
+
72
+
The `ElasticsearchEntityMapper` can use metadata to drive the mapping of objects to documents. The following annotations are available:
73
+
74
+
* `@Id`: Applied at the field level to mark the field used for identity purpose.
75
+
* `@Document`: Applied at the class level to indicate this class is a candidate for mapping to the database. You can specify the index name and index type where the document will be stored.
76
+
* `@Transient`: By default all private fields are mapped to the document, this annotation excludes the field where it is applied from being stored in the database
77
+
* `@PersistenceConstructor`: Marks a given constructor - even a package protected one - to use when instantiating the object from the database. Constructor arguments are mapped by name to the key values in the retrieved Document.
78
+
* `@Field`: Applied at the field level and described the name of the field as it will be represented in the Elasticsearch document thus allowing the name to be different than the fieldname of the class.
79
+
80
+
The mapping metadata infrastructure is defined in a separate spring-data-commons project that is technology agnostic.
81
+
69
82
[[elasticsearch.mapping.meta-model.rules]]
70
83
=== Mapping Rules
71
84
72
85
==== Type Hints
73
86
74
-
Mapping uses _type hints_ embedded in the document sent to the server to allow generic type mapping. Those type hints are
75
-
represented as `_class` attributes within the document on the server and will be written for each aggregate root.
87
+
Mapping uses _type hints_ embedded in the document sent to the server to allow generic type mapping.
88
+
Those type hints are represented as `_class` attributes within the document and are written for each aggregate root.
76
89
77
90
.Type Hints
78
91
====
@@ -123,8 +136,7 @@ public class Person {
123
136
<1> The configured alias is used when writing the entity.
124
137
====
125
138
126
-
NOTE: Type hints will not be written for nested Objects unless the properties type is `Object`, an interface or the
127
-
actual value type does not match the properties declaration.
139
+
NOTE: Type hints will not be written for nested Objects unless the properties type is `Object`, an interface or the actual value type does not match the properties declaration.
128
140
129
141
==== Geospatial Types
130
142
@@ -152,8 +164,7 @@ public class Address {
152
164
153
165
==== Collections
154
166
155
-
For values inside Collections apply the same mapping rules as for aggregate roots when it comes to _type hints_
156
-
and <<elasticsearch.mapping.meta-model.conversions>>.
167
+
For values inside Collections apply the same mapping rules as for aggregate roots when it comes to _type hints_ and <<elasticsearch.mapping.meta-model.conversions>>.
157
168
158
169
.Collections
159
170
====
@@ -179,8 +190,7 @@ public class Person {
179
190
180
191
==== Maps
181
192
182
-
For values inside Maps apply the same mapping rules as for aggregate roots when it comes to _type hints_
183
-
and <<elasticsearch.mapping.meta-model.conversions>>.
193
+
For values inside Maps apply the same mapping rules as for aggregate roots when it comes to _type hints_ and <<elasticsearch.mapping.meta-model.conversions>>.
184
194
However the Map key needs to a String to be processed by Elasticsearch.
185
195
186
196
.Collections
@@ -214,8 +224,7 @@ public class Person {
214
224
[[elasticsearch.mapping.meta-model.conversions]]
215
225
=== Custom Conversions
216
226
217
-
Looking at the `Configuration` from the <<elasticsearch.mapping.meta-model, previous section>> `ElasticsearchCustomConversions`
218
-
allows to register specific rules for mapping domain and simple types.
227
+
Looking at the `Configuration` from the <<elasticsearch.mapping.meta-model, previous section>> `ElasticsearchCustomConversions` allows registering specific rules for mapping domain and simple types.
0 commit comments