|
@@ -5,34 +5,53 @@ The get field mapping API allows you to retrieve mapping definitions for one or
|
|
|
This is useful when you do not need the complete type mapping returned by
|
|
|
the <<indices-get-mapping>> API.
|
|
|
|
|
|
-The following returns the mapping of the field `text` only:
|
|
|
+For example, consider the following mapping:
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
-GET /twitter/_mapping/tweet/field/message
|
|
|
+PUT publications
|
|
|
+{
|
|
|
+ "mappings": {
|
|
|
+ "article": {
|
|
|
+ "properties": {
|
|
|
+ "id": { "type": "text" },
|
|
|
+ "title": { "type": "text"},
|
|
|
+ "abstract": { "type": "text"},
|
|
|
+ "author": {
|
|
|
+ "properties": {
|
|
|
+ "id": { "type": "text" },
|
|
|
+ "name": { "type": "text" }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
--------------------------------------------------
|
|
|
+// TESTSETUP
|
|
|
// CONSOLE
|
|
|
-// TEST[setup:twitter]
|
|
|
|
|
|
-For which the response is (assuming `text` is a default string field):
|
|
|
+The following returns the mapping of the field `title` only:
|
|
|
+
|
|
|
+[source,js]
|
|
|
+--------------------------------------------------
|
|
|
+GET publications/_mapping/article/field/title
|
|
|
+--------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+
|
|
|
+For which the response is:
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
{
|
|
|
- "twitter": {
|
|
|
+ "publications": {
|
|
|
"mappings": {
|
|
|
- "tweet": {
|
|
|
- "message": {
|
|
|
- "full_name": "message",
|
|
|
+ "article": {
|
|
|
+ "title": {
|
|
|
+ "full_name": "title",
|
|
|
"mapping": {
|
|
|
- "message": {
|
|
|
- "type": "text",
|
|
|
- "fields": {
|
|
|
- "keyword": {
|
|
|
- "type": "keyword",
|
|
|
- "ignore_above": 256
|
|
|
- }
|
|
|
- }
|
|
|
+ "title": {
|
|
|
+ "type": "text"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -43,7 +62,6 @@ For which the response is (assuming `text` is a default string field):
|
|
|
--------------------------------------------------
|
|
|
// TESTRESPONSE
|
|
|
|
|
|
-
|
|
|
[float]
|
|
|
=== Multiple Indices, Types and Fields
|
|
|
|
|
@@ -69,46 +87,54 @@ GET /_all/_mapping/tw*/field/*.id
|
|
|
[float]
|
|
|
=== Specifying fields
|
|
|
|
|
|
-The get mapping api allows you to specify one or more fields separated with by a comma.
|
|
|
-You can also use wildcards. The field names can be any of the following:
|
|
|
+The get mapping api allows you to specify a comma-separated list of fields.
|
|
|
|
|
|
-[horizontal]
|
|
|
-Full names:: the full path, including any parent object name the field is
|
|
|
- part of (ex. `user.id`).
|
|
|
-Field names:: the name of the field without the path to it (ex. `id` for `{ "user" : { "id" : 1 } }`).
|
|
|
+For instance to select the `id` of the `author` field, you must use its full name `author.id`.
|
|
|
|
|
|
-The above options are specified in the order the `field` parameter is resolved.
|
|
|
-The first field found which matches is returned. This is especially important
|
|
|
-if index names or field names are used as those can be ambiguous.
|
|
|
+[source,js]
|
|
|
+--------------------------------------------------
|
|
|
+GET publications/_mapping/article/field/author.id,abstract,name
|
|
|
+--------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
|
|
|
-For example, consider the following mapping:
|
|
|
+returns:
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
- {
|
|
|
- "article": {
|
|
|
- "properties": {
|
|
|
- "id": { "type": "text" },
|
|
|
- "title": { "type": "text"},
|
|
|
- "abstract": { "type": "text"},
|
|
|
- "author": {
|
|
|
- "properties": {
|
|
|
- "id": { "type": "text" },
|
|
|
- "name": { "type": "text" }
|
|
|
- }
|
|
|
- }
|
|
|
+{
|
|
|
+ "publications": {
|
|
|
+ "mappings": {
|
|
|
+ "article": {
|
|
|
+ "author.id": {
|
|
|
+ "full_name": "author.id",
|
|
|
+ "mapping": {
|
|
|
+ "id": {
|
|
|
+ "type": "text"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "abstract": {
|
|
|
+ "full_name": "abstract",
|
|
|
+ "mapping": {
|
|
|
+ "abstract": {
|
|
|
+ "type": "text"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
--------------------------------------------------
|
|
|
+// TESTRESPONSE
|
|
|
|
|
|
-To select the `id` of the `author` field, you can use its full name `author.id`. `name` will return
|
|
|
-the field `author.name`:
|
|
|
+The get field mapping API also supports wildcard notation.
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
-curl -XGET "http://localhost:9200/publications/_mapping/article/field/author.id,abstract,name"
|
|
|
+GET publications/_mapping/article/field/a*
|
|
|
--------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
|
|
|
returns:
|
|
|
|
|
@@ -116,33 +142,38 @@ returns:
|
|
|
--------------------------------------------------
|
|
|
{
|
|
|
"publications": {
|
|
|
- "article": {
|
|
|
- "abstract": {
|
|
|
- "full_name": "abstract",
|
|
|
- "mapping": {
|
|
|
- "abstract": { "type": "text" }
|
|
|
- }
|
|
|
- },
|
|
|
- "author.id": {
|
|
|
- "full_name": "author.id",
|
|
|
- "mapping": {
|
|
|
- "id": { "type": "text" }
|
|
|
- }
|
|
|
- },
|
|
|
- "name": {
|
|
|
- "full_name": "author.name",
|
|
|
- "mapping": {
|
|
|
- "name": { "type": "text" }
|
|
|
+ "mappings": {
|
|
|
+ "article": {
|
|
|
+ "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"
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
--------------------------------------------------
|
|
|
-
|
|
|
-Note how the response always use the same fields specified in the request as keys.
|
|
|
-The `full_name` in every entry contains the full name of the field whose mapping were returned.
|
|
|
-This is useful when the request can refer to to multiple fields.
|
|
|
+// TESTRESPONSE
|
|
|
|
|
|
[float]
|
|
|
=== Other options
|