@@ -7,11 +7,11 @@ you are using Elasticsearch as a web session store. You may want to index the
7
7
session ID and last update time, but you don't need to query or run
8
8
aggregations on the session data itself.
9
9
10
- The `enabled` setting, which can be applied only to the mapping type and to
11
- <<object,`object`>> fields, causes Elasticsearch to skip parsing of the
12
- contents of the field entirely. The JSON can still be retrieved from the
13
- <<mapping-source-field,`_source`>> field, but it is not searchable or stored
14
- in any other way:
10
+ The `enabled` setting, which can be applied only to the top-level mapping
11
+ definition and to <<object,`object`>> fields, causes Elasticsearch to skip
12
+ parsing of the contents of the field entirely. The JSON can still be retrieved
13
+ from the <<mapping-source-field,`_source`>> field, but it is not searchable or
14
+ stored in any other way:
15
15
16
16
[source,js]
17
17
--------------------------------------------------
@@ -26,6 +26,7 @@ PUT my_index
26
26
"type": "date"
27
27
},
28
28
"session_data": { <1>
29
+ "type": "object",
29
30
"enabled": false
30
31
}
31
32
}
@@ -55,7 +56,7 @@ PUT my_index/_doc/session_2
55
56
<2> Any arbitrary data can be passed to the `session_data` field as it will be entirely ignored.
56
57
<3> The `session_data` will also ignore values that are not JSON objects.
57
58
58
- The entire mapping type may be disabled as well, in which case the document is
59
+ The entire mapping may be disabled as well, in which case the document is
59
60
stored in the <<mapping-source-field,`_source`>> field, which means it can be
60
61
retrieved, but none of its contents are indexed in any way:
61
62
@@ -84,10 +85,34 @@ GET my_index/_doc/session_1 <2>
84
85
GET my_index/_mapping <3>
85
86
--------------------------------------------------
86
87
// CONSOLE
87
- <1> The entire mapping type is disabled.
88
+ <1> The entire mapping is disabled.
88
89
<2> The document can be retrieved.
89
90
<3> Checking the mapping reveals that no fields have been added.
90
91
91
92
TIP: The `enabled` setting can be updated on existing fields
92
93
using the <<indices-put-mapping,PUT mapping API>>.
93
94
95
+ Note that because Elasticsearch completely skips parsing the field
96
+ contents, it is possible to add non-object data to a disabled field:
97
+ [source,js]
98
+ --------------------------------------------------
99
+ PUT my_index
100
+ {
101
+ "mappings": {
102
+ "properties": {
103
+ "session_data": {
104
+ "type": "object",
105
+ "enabled": false
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ PUT my_index/_doc/session_1
112
+ {
113
+ "session_data": "foo bar" <1>
114
+ }
115
+ --------------------------------------------------
116
+ // CONSOLE
117
+
118
+ <1> The document is added successfully, even though `session_data` contains non-object data.
0 commit comments