- Elasticsearch 的查詢語句
- 在開發初期,雖然可以明確查詢引數,但是往往還不能最終定義查詢的DSL的具體結構
- 通過Search Template 定義一個Contract
- 各司其職,解耦
POST products/_search/template
{
"id":"",
"params": {
"q":""
}
}
POST _aliases
{
"actions": [
{
"add": {
"index": "products",
"alias": "products_today"//為索引頂一個別名
}
}
]
}
//通過別名讀寫資料
PUT products_today/_doc/1
{
}
POST _aliases
{
"actions": [
{
"add": {
"index": "movies-2019",
"alias": "movies-lastest-highrate",
"filter": {
"range": {
"rating": {
"gte": 4
}
}
}
}
}
]
}
POST movies-lastest-highrate/_search
{
"query": {
"match_all": {}
}
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結