demo
DELETE twitter
PUT twitter
{}
PUT twitter/_mapping
{
"properties": {
"email": {
"type": "keyword"
}
}
}
#
# 1. 新属性可以被加到对象数据域中
# 2. 新的多字段可以加入到已有字段中
# 3. 可以更新 ignore_above
# 字符串中 ignore_above 以上的数据不会被索引、存储
#
PUT twitter/_mapping
{
"properties": {
"name": {
"properties": {
"last": {
"type": "text"
}
}
},
"user_id": {
"type": "keyword",
"ignore_above": 100
}
}
}
PUT twitter/_mapping
{
"properties": {
"name": {
"properties": {
"first": {
"type": "text"
}
}
},
"user_id": {
"type": "keyword",
"ignore_above": 80
}
}
}
GET twitter/_mapping
GET /_all/_mapping
GET /_mapping
DELETE twitter
PUT twitter
{
"mappings": {
"properties": {
"id": {
"type":"keyword"
},
"title":{
"type":"text"
},
"abstract":{
"type":"text"
},
"author":{
"properties": {
"user_id":{
"type":"keyword"
},
"name":{
"properties":{
"first":{
"type":"text"
},
"last":{
"type":"text"
}
}
}
}
}
}
}
}
GET twitter/_mapping
GET twitter/_mapping/field/author.name.first
# Create the two indices
PUT twitter_v1
PUT twitter_v2
# Update both mappings
PUT /twitter_v1,twitter_v2/_mapping
{
"properties": {
"user_name": {
"type": "text"
}
}
}
GET /twitter_v1,twitter_v2/_mapping/field/user_name
GET /_all/_mapping/field/user_name,name
GET /_all/_mapping/field/*.id
GET /_all/_mapping/field/a*
HEAD /twitter-1/_mapping/my_type
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter",
"alias": "twitter_alias"
}
}
]
}
POST /_aliases
{
"actions": [
{
"remove": {
"index": "twitter",
"alias": "twitter_alias"
}
}
]
}
POST /_aliases
{
"actions": [
{
"remove": {
"index": "twitter_v1",
"alias": "twitter_alias"
}
},
{
"add": {
"index": "twitter_v2",
"alias": "twitter_alias"
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter_v1",
"alias": "twitter_alias"
}
},
{
"add": {
"index": "twitter_v2",
"alias": "twitter_alias"
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"indices": [
"twitter_v1",
"twitter_v2"
],
"alias": "twitter_alias"
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter*",
"alias": "twitter_alias"
}
}
]
}
PUT test
PUT test_2
POST /_aliases
{
"actions": [
{
"add": {
"index": "test_2",
"alias": "test"
}
},
{
"remove_index": {
"index": "test"
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter",
"alias": "twitter_cn",
"filter": {
"term": {
"country": "china"
}
}
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter",
"alias": "twitter_alias",
"routing": "1"
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter",
"alias": "twitter_alias",
"search_routing": "1,2",
"index_routing": "2"
}
}
]
}
GET /twitter_alias/_search?q=user:kimchy&routing=2,3
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter_v1",
"alias": "twitter_alias_writable",
"is_write_index": true
}
},
{
"add": {
"index": "twitter_v1",
"alias": "twitter_alias"
}
}
]
}
POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter_v1",
"alias": "twitter_alias",
"is_write_index": false
}
},
{
"add": {
"index": "twitter_v2",
"alias": "twitter_alias",
"is_write_index": true
}
}
]
}
PUT /twitter_v1/_alias/twitter_alias
PUT /twitter_v1/_alias/twitter_cn
{
"filter": {
"term": {
"country": "china"
}
}
}
PUT /twitter_v1
{
"mappings": {
"properties": {
"country": {
"type": "text"
}
}
},
"aliases": {
"twiter_cn": {
"filter": {
"term": {
"country": "cn"
}
}
},
"twitter_alias": {}
}
}
#
# DELETE /{index}/_alias/{name}
# index * | _all | glob pattern | name1, name2, …
# name * | _all | glob pattern | name1, name2, …
#
DELETE /twitter_v1/_alias/twitter_cn
GET /twitter_v1/_alias/*
GET /_alias/twitter_alias
GET /_alias/twitter*
HEAD /_alias/twitter_alias
HEAD /_alias/twitter*
HEAD /twitter_v1/_alias/*