Example uses basic HTTP, which translate easily to cURL and other HTTP applications. They also match the Sense syntax, which will be renamed to Console in Kibana 5.0.
Note: The example inserts <#>
to help draw attention to parts. Those should be removed if you copy it!
PUT /my_index <1>
{
"mappings": {
"my_type": { <2>
"properties": {
"field1": {
"type": "long"
},
"field2": {
"type": "integer"
},
"object1": {
"type": "object",
"properties": {
"field1" : {
"type": "float"
}
}
}
}
}
},
"my_other_type": {
"properties": {
"field1": {
"type": "long" <3>
},
"field3": { <4>
"type": "double"
}
}
}
}
index
using the create index endpoint.type
.type
s within the same index
must share the same definition! ES 1.x did not strictly enforce this behavior, but it was an implicit requirement. ES 2.x and above strictly enforce this behavior.type
s are okay.Indexes (or indices) contain types. Types are a convenient mechanism for separating documents, but they require you to define -- either dynamically/automatically or explicitly -- a mapping for each type that you use. If you define 15 types in an index, then you have 15 unique mappings.
See the remarks for more details about this concept and why you may or may not want to use types.