Search Template 目标:解耦程序和搜索DSL
创建模板:
POST _scripts/<templateid>
{
"script": {
"lang": "mustache",
"source": {
"query": {
"match": {
"title": "{{query_string}}"
}
}
}
}
}
POST _scripts/tmdb
{
"script":{
"lang": "mustache",
"source": {
"_source":["firstname","lastname","email"]
},
"query":{
"multi_match": {
"query": "{{q}}",
"fields": ["firstname","lastname","email"]
}
}
}
}
查看:
GET _scripts/tmdb
- 调用:
POST tmdb/_search/template{ "id": "tmdb", "params": { "q": "strong" }}
Index Alias:实现零停机运维
POST _aliases
{
"actions": [
{
"add": {
"index": "accounts",
"alias": "accountData"
}
},
{
"remove": {
"index": "address",
"alias": "addressData"
}
}
]
}