mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
* Default include_type_name to false for get and put mappings. * Default include_type_name to false for get field mappings. * Add a constant for the default include_type_name value. * Default include_type_name to false for get and put index templates. * Default include_type_name to false for create index. * Update create index calls in REST documentation to use include_type_name=true. * Some minor clean-ups around the get index API. * In REST tests, use include_type_name=true by default for index creation. * Make sure to use 'expression == false'. * Clarify the different IndexTemplateMetaData toXContent methods. * Fix FullClusterRestartIT#testSnapshotRestore. * Fix the ml_anomalies_default_mappings test. * Fix GetFieldMappingsResponseTests and GetIndexTemplateResponseTests. We make sure to specify include_type_name=true during xContent parsing, so we continue to test the legacy typed responses. XContent generation for the typeless responses is currently only covered by REST tests, but we will be adding unit test coverage for these as we implement each typeless API in the Java HLRC. This commit also refactors GetMappingsResponse to follow the same appraoch as the other mappings-related responses, where we read include_type_name out of the xContent params, instead of creating a second toXContent method. This gives better consistency in the response parsing code. * Fix more REST tests. * Improve some wording in the create index documentation. * Add a note about types removal in the create index docs. * Fix SmokeTestMonitoringWithSecurityIT#testHTTPExporterWithSSL. * Make sure to mention include_type_name in the REST docs for affected APIs. * Make sure to use 'expression == false' in FullClusterRestartIT. * Mention include_type_name in the REST templates docs.
98 lines
2.6 KiB
Plaintext
98 lines
2.6 KiB
Plaintext
[[enabled]]
|
|
=== `enabled`
|
|
|
|
Elasticsearch tries to index all of the fields you give it, but sometimes you
|
|
want to just store the field without indexing it. For instance, imagine that
|
|
you are using Elasticsearch as a web session store. You may want to index the
|
|
session ID and last update time, but you don't need to query or run
|
|
aggregations on the session data itself.
|
|
|
|
The `enabled` setting, which can be applied only to the mapping type and to
|
|
<<object,`object`>> fields, causes Elasticsearch to skip parsing of the
|
|
contents of the field entirely. The JSON can still be retrieved from the
|
|
<<mapping-source-field,`_source`>> field, but it is not searchable or stored
|
|
in any other way:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
PUT my_index?include_type_name=true
|
|
{
|
|
"mappings": {
|
|
"_doc": {
|
|
"properties": {
|
|
"user_id": {
|
|
"type": "keyword"
|
|
},
|
|
"last_updated": {
|
|
"type": "date"
|
|
},
|
|
"session_data": { <1>
|
|
"enabled": false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
PUT my_index/_doc/session_1
|
|
{
|
|
"user_id": "kimchy",
|
|
"session_data": { <2>
|
|
"arbitrary_object": {
|
|
"some_array": [ "foo", "bar", { "baz": 2 } ]
|
|
}
|
|
},
|
|
"last_updated": "2015-12-06T18:20:22"
|
|
}
|
|
|
|
PUT my_index/_doc/session_2
|
|
{
|
|
"user_id": "jpountz",
|
|
"session_data": "none", <3>
|
|
"last_updated": "2015-12-06T18:22:13"
|
|
}
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
<1> The `session_data` field is disabled.
|
|
<2> Any arbitrary data can be passed to the `session_data` field as it will be entirely ignored.
|
|
<3> The `session_data` will also ignore values that are not JSON objects.
|
|
|
|
The entire mapping type may be disabled as well, in which case the document is
|
|
stored in the <<mapping-source-field,`_source`>> field, which means it can be
|
|
retrieved, but none of its contents are indexed in any way:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
PUT my_index?include_type_name=true
|
|
{
|
|
"mappings": {
|
|
"_doc": { <1>
|
|
"enabled": false
|
|
}
|
|
}
|
|
}
|
|
|
|
PUT my_index/_doc/session_1
|
|
{
|
|
"user_id": "kimchy",
|
|
"session_data": {
|
|
"arbitrary_object": {
|
|
"some_array": [ "foo", "bar", { "baz": 2 } ]
|
|
}
|
|
},
|
|
"last_updated": "2015-12-06T18:20:22"
|
|
}
|
|
|
|
GET my_index/_doc/session_1 <2>
|
|
|
|
GET my_index/_mapping <3>
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
<1> The entire `_doc` mapping type is disabled.
|
|
<2> The document can be retrieved.
|
|
<3> Checking the mapping reveals that no fields have been added.
|
|
|
|
TIP: The `enabled` setting can be updated on existing fields
|
|
using the <<indices-put-mapping,PUT mapping API>>.
|
|
|