es中match查询中,查询字符串分词后,默认是or或者的关系。
语法
operator:用来控制match查询匹配词条的逻辑条件,默认值是or,如果设置为and,表示查询满足所有条件
minimum_should_match:当operator参数设置为or时,该参数用来控制应该匹配的分词的最少数量。
当参数operator使用默认值时,参数minimum_should_match设置每个子查询应该匹配多少个分词,默认值是1,例如,设置minimum_should_match为1,那么搜索的字段中至少含有一个分词。
match or实例
GET /bank/_search { "from":1, "size":5, "query": { "match": { "smsContent": { "query": "java 学习", "operator": "or" //或者关系 "minimum_should_match": 2 } } } }
smsContent中包含java或者学习的内容,minimum_should_match等于2表示这2个分词在内容中必须大于2次
match and实例
GET /bank/_search { "query": { "match": { "smsContent": { "query": "java 学习", "operator": "and" //并且关系 } } } }
smsContent中包含java并且学习的内容