各种query搜索语法
1、match all 所有数据
2、match 匹配某一个的field的包含搜索关键词,注意“my elasticsearch article” 会被分词 搜索,比如分成了my ,elasticsearch, article, 三个词,只要有一个document包含其中一个就算匹配成功。
3、multi match 将搜索关键词使用在多个field上
4、range query 区间搜索,可以放在query 也可以放在filter里面
5、term query 必须精确匹配,"test hello" 被当成一个整体就行去搜索,不会去分词。注意这个也和mapping 中的字段类型设置有关系,参数index 必须设置not_analyzed ,否则的话如果分词了,"test hello"就会整体搜索不到。对于string类型的filed index 默认值是: analyzed.
如果你设置了not_analyzed,效果和term query 一样了,直接使用query 查询就行了,因为not_analyzed代表不分词。
6、terms query term多关键词匹配
GET /_search
{
}
7、exist query(2.x中的查询,现在已经不提供了)
Last updated
Was this helpful?