https://www.jianshu.com/p/7247ac3663f7

查询方法

  • term 不分词,精确查找
  • match 会分词,模糊匹配,需要指定字段名,比如”hello world”会进行拆分为hello和world
  • match_phase 会分词,但是需要结果中也包含所有的分词,而且顺序要求一样
  • query_string 会分词,在所有字段中搜索
  • multi_match 不分词,它只会匹配他的相似度,根据提供的fields,逐个进行匹配

条件控制

https://blog.csdn.net/SongYuxinIT/article/details/120678401

  • must 与
  • should 或

标准分析器

https://www.elastic.co/guide/en/elasticsearch/guide/2.x/most-fields.html
标明 col.std 还应该额外写上字段

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"query":
{
"bool":
{
"should": [
{
"multi_match":
{
"query": "Wooden Stool",
"fields": ["name^1", "name.std"],
"type": "most_fields",
"tie_breaker": 0.3
}
}]
}

}
}

大小写问题

https://www.jianshu.com/p/f48ea2b7827c
https://blog.csdn.net/qq_34412985/article/details/105131567

英文索引可能是小写,查询时候也要小写

term和terms

  • term匹配一个
  • terms只要文档中在多个词中匹配一个就会返回

match_phrase

text和keyword

text类型:会分词,先把对象进行分词处理,然后再再存入到es中。
keyword:不分词,没有把es中的对象进行分词处理,而是存入了整个对象!

数组字段

数组定义和单个字段没有不同,推数组上去就会被识别为数组