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": "上海" } } ] } } }