ES基础(二十四)使用 Search Template 和 Index Alias 查询
课程Demo
POST _scripts/tmdb { "script": { "lang": "mustache", "source": { "_source": [ "title","overview" ], "size": 20, "query": { "multi_match": { "query": "{{q}}", "fields": ["title","overview"] } } } } } DELETE _scripts/tmdb GET _scripts/tmdb POST tmdb/_search/template { "id":"tmdb", "params": { "q": "basketball with cartoon aliens" } } PUT movies-2019/_doc/1 { "name":"the matrix", "rating":5 } PUT movies-2019/_doc/2 { "name":"Speed", "rating":3 } POST _aliases { "actions": [ { "add": { "index": "movies-2019", "alias": "movies-latest" } } ] } POST movies-latest/_search { "query": { "match_all": {} } } POST _aliases { "actions": [ { "add": { "index": "movies-2019", "alias": "movies-lastest-highrate", "filter": { "range": { "rating": { "gte": 4 } } } } } ] } POST movies-lastest-highrate/_search { "query": { "match_all": {} } }
本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/14196919.html