mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-26 23:07:45 +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.
180 lines
4.3 KiB
Plaintext
180 lines
4.3 KiB
Plaintext
[[indices-get-field-mapping]]
|
|
== Get Field Mapping
|
|
|
|
The get field mapping API allows you to retrieve mapping definitions for one or more fields.
|
|
This is useful when you do not need the complete type mapping returned by
|
|
the <<indices-get-mapping>> API.
|
|
|
|
For example, consider the following mapping:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
PUT publications?include_type_name=true
|
|
{
|
|
"mappings": {
|
|
"_doc": {
|
|
"properties": {
|
|
"id": { "type": "text" },
|
|
"title": { "type": "text"},
|
|
"abstract": { "type": "text"},
|
|
"author": {
|
|
"properties": {
|
|
"id": { "type": "text" },
|
|
"name": { "type": "text" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
// TESTSETUP
|
|
// CONSOLE
|
|
|
|
The following returns the mapping of the field `title` only:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
GET publications/_mapping/field/title
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
|
|
For which the response is:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
"publications": {
|
|
"mappings": {
|
|
"title": {
|
|
"full_name": "title",
|
|
"mapping": {
|
|
"title": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
// TESTRESPONSE
|
|
|
|
[float]
|
|
=== Multiple Indices and Fields
|
|
|
|
The get field mapping API can be used to get the mapping of multiple fields from more than one index
|
|
with a single call. General usage of the API follows the
|
|
following syntax: `host:port/{index}/_mapping/field/{field}` where
|
|
`{index}` and `{field}` can stand for comma-separated list of names or wild cards. To
|
|
get mappings for all indices you can use `_all` for `{index}`. The
|
|
following are some examples:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
GET /twitter,kimchy/_mapping/field/message
|
|
|
|
GET /_all/_mapping/field/message,user.id
|
|
|
|
GET /_all/_mapping/field/*.id
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
// TEST[setup:twitter]
|
|
// TEST[s/^/PUT kimchy\nPUT book\n/]
|
|
|
|
[float]
|
|
=== Specifying fields
|
|
|
|
The get mapping api allows you to specify a comma-separated list of fields.
|
|
|
|
For instance to select the `id` of the `author` field, you must use its full name `author.id`.
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
GET publications/_mapping/field/author.id,abstract,name
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
|
|
returns:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
"publications": {
|
|
"mappings": {
|
|
"author.id": {
|
|
"full_name": "author.id",
|
|
"mapping": {
|
|
"id": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
},
|
|
"abstract": {
|
|
"full_name": "abstract",
|
|
"mapping": {
|
|
"abstract": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
// TESTRESPONSE
|
|
|
|
The get field mapping API also supports wildcard notation.
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
GET publications/_mapping/field/a*
|
|
--------------------------------------------------
|
|
// CONSOLE
|
|
|
|
returns:
|
|
|
|
[source,js]
|
|
--------------------------------------------------
|
|
{
|
|
"publications": {
|
|
"mappings": {
|
|
"author.name": {
|
|
"full_name": "author.name",
|
|
"mapping": {
|
|
"name": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
},
|
|
"abstract": {
|
|
"full_name": "abstract",
|
|
"mapping": {
|
|
"abstract": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
},
|
|
"author.id": {
|
|
"full_name": "author.id",
|
|
"mapping": {
|
|
"id": {
|
|
"type": "text"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
--------------------------------------------------
|
|
// TESTRESPONSE
|
|
|
|
[float]
|
|
=== Other options
|
|
|
|
[horizontal]
|
|
`include_defaults`::
|
|
|
|
adding `include_defaults=true` to the query string will cause the response
|
|
to include default values, which are normally suppressed.
|