Mappings¶
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¶
The date type¶
The boolean type¶
Boolean type reference and it’s boolean
not Boolean
.
Multi fields¶
You can store the same source field in several index fields, analyzed differently.
Object type¶
You can define a field to contain other fields.
Root object type¶
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
}
}
}