match
- match的查詢詞會被分詞
- match_phrase 不會分詞
- match_phrase 可對多個字段進行匹配html
term
- term表明徹底匹配,不進行分詞器分析
- term 查詢的字段須要在mapping的時候定義好,不然可能詞被分詞。傳入指定的字符串,查不到數據app
bool聯合查詢
- must should must_not
- must 徹底匹配
- should 至少知足一個
- must_not不匹配elasticsearch
舉個栗子分佈式
{ "query": { "bool": { "must": { "term": { "content": "寶馬" } }, "must_not": { "term": { "tags": "寶馬" } } } } }
POST product/_search { "size": 20, "query": { "bool": { "must": [ { "term": { "attribute": { "value": "13" } } }, { "match": { "departureCitys": "上海" } } ] } } }