#Index Alias 经测试,可以对不同的索引起相同的别名
DELETE /titles
DELETE /titles2
PUT /titles
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "english",
"fields": {"std": {"type": "text","analyzer": "standard"}}
}
}
}
}
PUT /titles2
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "english",
"fields": {"std": {"type": "text","analyzer": "standard"}}
}
}
}
}
POST titles/_bulk
{ "index": { "_id": 1 }}
{ "title": "My dog barks" }
{ "index": { "_id": 2 }}
{ "title": "I see a lot of barking dogs on the road " }
POST titles2/_bulk
{ "index": { "_id": 3 }}
{ "title": "My dog barks" }
{ "index": { "_id": 4 }}
{ "title": "I see a lot of barking dogs on the road " }
POST _aliases
{
"actions": [
{
"add": {
"index": "titles",
"alias": "aliastitle"
}
}
]
}
POST _aliases
{
"actions": [
{
"add": {
"index": "titles2",
"alias": "aliastitle"
}
}
]
}
GET /aliastitle/_search
{
"query": {
"multi_match": {
"query": "barking dogs",
"type": "most_fields",
"fields": [ "title", "title.std" ]
}
}
}
GET /aliastitle/_search
{
"query": {
"multi_match": {
"query": "barking dogs",
"type": "most_fields",
"fields": [ "title^10", "title.std" ]
}
}
}
展开
作者回复: alias可以指定多个index,但是只能指定一个index用于写入数据