索引操作

Indices

Types

类型即对应了关系型数据库中表的地位,那么常见的基本操作也就包括了对于类型的创建 ( 类比于表创建 ) 与类型结构的修正 ( 类比于表结构修正 )。

// Creates an index called twitter with the message field in the tweet mapping type.
PUT twitter
{
"mappings": {
"tweet": {
"properties": {
"message": {
"type": "string"
}
}
}
}
}
// Uses the PUT mapping API to add a new mapping type called user.
PUT twitter/_mapping/user
{
"properties": {
"name": {
"type": "string"
}
}
}
// Uses the PUT mapping API to add a new field called user_name to the tweet mapping type.
PUT twitter/_mapping/tweet
{
"properties": {
"user_name": {
"type": "string"
}
}
}