ES查詢優化之查詢過濾
過濾器種類
範圍過濾器
{ "post_filter":{ "range":{ "year":{ "gte":1930, "lte":1990 } } } }
exists過濾器:過濾掉給定欄位沒有值的文件
{ "post_filter":{ "exists":{ "field":"year" } } }
missing過濾器
{ "post_filter":{ "missing":{#過濾掉給定欄位有值或缺失的文件 "field":"year", "null_value":0, "existence":true } } }
指令碼過濾器
{ "post_filter":{ "script":{#過濾掉髮表在一個世紀以前的書 "script":"now - doc['year'].value > 100", "params":{"now":2012} } } }
型別過濾器
{ "post_filter":{ "type":{ "value":"book" } } }
限定過濾器
{ "post_filter":{ "limit":{ "value":1 } } }
識別符號過濾器
組合過濾器
{ "query": { "bool": { "must": { "range": { "year": { "gte": 1930, "lte": 1990 } } }, "should": { "term": { "available": true } }, "boost": 1 } } }
原文連結:https://segmentfault.com/a/1190000004429689