Semantics: How are document_type, mapping_type, and mapping defined and different?

I an indexing my documents with an explicit mapping that I have specified. These documents:

have a document type (_doc): a metadata label, the type of document being indexed.
have a mapping: Either dynamically established by ES or specified explicitly by me.
used to have a mapping type: used to represent the type of document or entity being indexed.

Could you share an example of what you're saying?


Adapted from the docs:

If I do not specify the mapping it is established dynamically by ES:

PUT /customer/_doc/1
         "name": "John Doe"

GET /customer/_doc/1

    "_index" : "customer",
    "_type" : "_doc",
    "_id" : "1",
    "_version" : 1,
    "_seq_no" : 26,
    "_primary_term" : 4,
    "found" : true,
      "_source" : {
        "name": "John Doe"

If I specify the field data-type for name, I am giving an explicit mapping for the index.

PUT customer
      "mappings": {
          "properties": {
          "name": {
              "type":  "text"

So, the mapping is either established dynamically by ES or specified (as above) explicitly by me.

If I established an explicit mapping for a document, was this known as the mapping type?

The docs discuss removal of mapping types and say that

Each document had a _type meta-field containing the type name, and searches could be limited to one or more types by specifying the type name(s) in the URL:

GET twitter/user,tweet/_search
    "query": {
      "match": {
          "user_name": "kimchy"

I don't understand if the _doc field or _type field currently or used to be referred to as a document-type or mapping-type. I would like to understand what a document-type or mapping-type is and how they relate to how the mapping is generated for an index.

I have seen the term document-type used casually and have seen it in a legacy project, but I don't see it defined in the ES docs and so am confused as to what exactly a document-type is and if it is a synonym for the deprecated mapping-type.

In your pasted example, the values of the _type are user and tweet.

But ignore references to anything like _type or document types, they are deprecated and will be removed in 8.0. _doc is a default we use in 7.X to get users used to this being gone, so they're similar to user and tweet as per your example.

Mapping types are field definitions. That is anything as listed in the docs -

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.