Mappings

Mappings API

Mappings reference

Intro to Mappings in the Guide

Types and Mappings in the Guide

Example mapping for a tweet doctype:

{
    "tweet" : {
        "properties" : {
            "message" : {
                "type" : "string",
                "store" : true,
                "index" : "analyzed",
                "null_value" : "na"
            },
            "user" : {
                "type" : "string",
                "index" : "not_analyzed",
                "norms" : {
                    "enabled" : false
                }
            },
            "postDate" : {"type" : "date"},
            "priority" : {"type" : "integer"},
            "rank" : {"type" : "float"}
        }
    }
}

The string type

The string type is analyzed as full text by default.

String type reference includes all the possible attributes.

The number type

Number type reference

The date type

Date type reference

The boolean type

Boolean type reference and it’s boolean not Boolean.

Multi fields

Multi fields reference

You can store the same source field in several index fields, analyzed differently.

Object type

Object Type Ref

You can define a field to contain other fields.

Root object type

Root object type ref

Root object in guide - better

The top-level doc type in a mapping is also an object type, but has some special characteristics. For example, you can set the default analyzers that fields without an explicit analyzer will use.

You can also turn off dynamic mapping for a doctype, though the Root object type ref doesn’t mention this. See Dynamic mapping. You can even turn it back on for one field. Example:

{
    "my_type": {
        "dynamic":      "strict",
        "properties": {
            ...
            "stash": {
                "type": "object",
                "dynamic": True
        }
    }
}