Skip to content

Commit f4703be

Browse files
authored
[DOCS] Reformat get field mapping API docs (#45700)
1 parent f12ea8a commit f4703be

File tree

1 file changed

+86
-38
lines changed

1 file changed

+86
-38
lines changed

docs/reference/indices/get-field-mapping.asciidoc

Lines changed: 86 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,70 @@
11
[[indices-get-field-mapping]]
2-
=== Get Field Mapping
2+
=== Get field mapping API
3+
++++
4+
<titleabbrev>Get field mapping</titleabbrev>
5+
++++
36

4-
The get field mapping API allows you to retrieve mapping definitions for one or more fields.
5-
This is useful when you do not need the complete type mapping returned by
6-
the <<indices-get-mapping>> API.
7+
Retrieves <<mapping,mapping definitions>> for one or more fields. This is useful
8+
if you don't need the <<indices-get-mapping,complete mapping>> of an index or
9+
your index contains a large number of fields.
710

8-
For example, consider the following mapping:
11+
[source,js]
12+
----
13+
GET /twitter/_mapping/field/user
14+
----
15+
// CONSOLE
16+
// TEST[setup:twitter]
17+
18+
19+
[[get-field-mapping-api-request]]
20+
==== {api-request-title}
21+
22+
`GET /_mapping/field/<field>`
23+
24+
`GET /<index>/_mapping/field/<field>`
25+
26+
27+
[[get-field-mapping-api-path-params]]
28+
==== {api-path-parms-title}
29+
30+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
31+
32+
`<field>`::
33+
(Optional, string) Comma-separated list or wildcard expression of fields used to
34+
limit returned information.
35+
36+
37+
[[get-field-mapping-api-query-params]]
38+
==== {api-query-parms-title}
39+
40+
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
41+
42+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
43+
44+
include::{docdir}/rest-api/common-parms.asciidoc[tag=include-type-name]
45+
46+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
47+
48+
`include_defaults`::
49+
(Optional, boolean) If `true`, the response includes default mapping values.
50+
Defaults to `false`.
51+
52+
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
53+
54+
55+
[[get-field-mapping-api-example]]
56+
==== {api-examples-title}
57+
58+
[[get-field-mapping-api-basic-ex]]
59+
===== Example with index setup
60+
61+
You can provide field mappings when creating a new index. The following
62+
<<indices-create-index, create index>> API request creates the `publications`
63+
index with several field mappings.
964

1065
[source,js]
1166
--------------------------------------------------
12-
PUT publications
67+
PUT /publications
1368
{
1469
"mappings": {
1570
"properties": {
@@ -26,7 +81,6 @@ PUT publications
2681
}
2782
}
2883
--------------------------------------------------
29-
// TESTSETUP
3084
// CONSOLE
3185

3286
The following returns the mapping of the field `title` only:
@@ -36,8 +90,9 @@ The following returns the mapping of the field `title` only:
3690
GET publications/_mapping/field/title
3791
--------------------------------------------------
3892
// CONSOLE
93+
// TEST[continued]
3994

40-
For which the response is:
95+
The API returns the following response:
4196

4297
[source,js]
4398
--------------------------------------------------
@@ -58,30 +113,8 @@ For which the response is:
58113
--------------------------------------------------
59114
// TESTRESPONSE
60115

61-
[float]
62-
==== Multiple Indices and Fields
63-
64-
The get field mapping API can be used to get the mapping of multiple fields from more than one index
65-
with a single call. General usage of the API follows the
66-
following syntax: `host:port/{index}/_mapping/field/{field}` where
67-
`{index}` and `{field}` can stand for comma-separated list of names or wild cards. To
68-
get mappings for all indices you can use `_all` for `{index}`. The
69-
following are some examples:
70-
71-
[source,js]
72-
--------------------------------------------------
73-
GET /twitter,kimchy/_mapping/field/message
74-
75-
GET /_all/_mapping/field/message,user.id
76-
77-
GET /_all/_mapping/field/*.id
78-
--------------------------------------------------
79-
// CONSOLE
80-
// TEST[setup:twitter]
81-
// TEST[s/^/PUT kimchy\nPUT book\n/]
82-
83-
[float]
84-
==== Specifying fields
116+
[[get-field-mapping-api-specific-fields-ex]]
117+
===== Specifying fields
85118

86119
The get mapping api allows you to specify a comma-separated list of fields.
87120

@@ -92,6 +125,7 @@ For instance to select the `id` of the `author` field, you must use its full nam
92125
GET publications/_mapping/field/author.id,abstract,name
93126
--------------------------------------------------
94127
// CONSOLE
128+
// TEST[continued]
95129

96130
returns:
97131

@@ -129,6 +163,7 @@ The get field mapping API also supports wildcard notation.
129163
GET publications/_mapping/field/a*
130164
--------------------------------------------------
131165
// CONSOLE
166+
// TEST[continued]
132167

133168
returns:
134169

@@ -167,11 +202,24 @@ returns:
167202
--------------------------------------------------
168203
// TESTRESPONSE
169204

170-
[float]
171-
==== Other options
205+
[[get-field-mapping-api-multi-index-ex]]
206+
===== Multiple indices and fields
172207

173-
[horizontal]
174-
`include_defaults`::
208+
The get field mapping API can be used to get the mapping of multiple fields from more than one index
209+
with a single call. General usage of the API follows the
210+
following syntax: `host:port/<index>/_mapping/field/<field>` where
211+
`<index>` and `<field>` can stand for comma-separated list of names or wild cards. To
212+
get mappings for all indices you can use `_all` for `<index>`. The
213+
following are some examples:
214+
215+
[source,js]
216+
--------------------------------------------------
217+
GET /twitter,kimchy/_mapping/field/message
175218
176-
adding `include_defaults=true` to the query string will cause the response
177-
to include default values, which are normally suppressed.
219+
GET /_all/_mapping/field/message,user.id
220+
221+
GET /_all/_mapping/field/*.id
222+
--------------------------------------------------
223+
// CONSOLE
224+
// TEST[setup:twitter]
225+
// TEST[s/^/PUT kimchy\nPUT book\n/]

0 commit comments

Comments
 (0)