Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetFieldMapping API #3941

Closed
bleskes opened this issue Oct 21, 2013 · 3 comments
Closed

GetFieldMapping API #3941

bleskes opened this issue Oct 21, 2013 · 3 comments

Comments

@bleskes
Copy link
Contributor

bleskes commented Oct 21, 2013

This new API allows retrieving the mappings for specific fields. This is offered as an alternative to traversing the results of the standard Get Mapping API, which returns the entire mapping for indices and types.

The new API is available under the following REST endpoints, allowing to resolve fields for multiple indices and types in one GET request:

/_mapping/field/{fields}
/{index}/_mapping/field/{fields}
/{index}/{type}/_mapping/field/{fields}

For example, the following call will return the mapping information for the text and user.name of an index of tweets:

curl -XGET "http://localhost:9200/twitter/tweet/_mapping/field/text,user.name"

Returns:

{
   "twitter": {
      "tweet": {
         "text": {
            "full_name": "text",
            "mapping": {
               "text": { "type": "string" }
            }
         },
         "user.name": {
            "full_name": "user.name",
            "mapping": { 
               "name": { "type": "string" }
            }
         }
      }
   }
}

Similar to other APIs, fields names can be one of the following (in resolution order):

  • Full names
  • Index names
  • Field name (excluding complete path)

The response will use the same naming specified in the url:

curl -XGET "http://localhost:9200/_mapping/field/name"

returns

{
   "twitter": {
      "tweet": {
         "name": {
            "full_name": "user.name",
            "mapping": {
               "name": { "type": "string" }
            }
         }
      }
   }
}

Last, you request outputting default values (suppressed by default):

curl -XGET "http://localhost:9200/_mapping/field/name?include_defaults=true" 
{
   "twitter": {
      "tweet": {
         "name": {
            "full_name": "user.name",
            "mapping": {
               "name": {
                  "type": "string",
                  "index_name": "name",
                  "boost": 1,
                  "index": "analyzed",
                  "store": false,
                  "term_vector": "no",
                  "omit_norms": false,
                  "index_options": "positions",
                  "analyzer": "default",
                  "postings_format": "default",
                  "doc_values_format": "default",
                  "similariry": "default",
                  "fielddata": {},
                  "null_value": null,
                  "include_in_all": false,
                  "position_offset_gap": 0,
                  "search_quote_analyzer": "default",
                  "ignore_above": -1
               }
            }
         }
      }
   }
}
@awick
Copy link

awick commented Oct 21, 2013

Will this support _meta?

Issue #2857

@bleskes
Copy link
Contributor Author

bleskes commented Oct 22, 2013

@awick sadly no. This does nothing more (or less) than exposing the current mapping infrastructure on a per field basis.

bleskes added a commit to bleskes/elasticsearch that referenced this issue Oct 29, 2013
This new API allows to get the mapping for a specific set of fields rather than get the whole index mapping and traverse it.
The fields to be retrieved can be specified by their full path, index name and field name and will be resolved in this order.
In case multiple field match, the first one will be returned.

Since we are now generating the output (rather then fall back to the stored mapping), you can specify `include_defaults`=true on the request to have default values returned.

Closes elastic#3941
@jugaadi
Copy link

jugaadi commented Oct 30, 2013

+1 for _meta

bleskes added a commit that referenced this issue Oct 30, 2013
This new API allows to get the mapping for a specific set of fields rather than get the whole index mapping and traverse it.
The fields to be retrieved can be specified by their full path, index name and field name and will be resolved in this order.
In case multiple field match, the first one will be returned.

Since we are now generating the output (rather then fall back to the stored mapping), you can specify `include_defaults`=true on the request to have default values returned.

Closes #3941
javanna pushed a commit to javanna/elasticsearch that referenced this issue Dec 27, 2013
brusic pushed a commit to brusic/elasticsearch that referenced this issue Jan 19, 2014
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
This new API allows to get the mapping for a specific set of fields rather than get the whole index mapping and traverse it.
The fields to be retrieved can be specified by their full path, index name and field name and will be resolved in this order.
In case multiple field match, the first one will be returned.

Since we are now generating the output (rather then fall back to the stored mapping), you can specify `include_defaults`=true on the request to have default values returned.

Closes elastic#3941
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants