- 【ES从入门到实战】十六、全文检索-ElasticSearch-
- 【ES从入门到实战】十四、全文检索-ElasticSearch-
- 【ES从入门到实战】十七、全文检索-ElasticSearch-
- 【ES从入门到实战】十九、全文检索-ElasticSearch-
- 【ES从入门到实战】二十、全文检索-ElasticSearch-
- 【ES从入门到实战】十八、全文检索-ElasticSearch-
- 【ES从入门到实战】十五、全文检索-ElasticSearch-
- 【ES从入门到实战】十二、全文检索-ElasticSearch-
- 【ES从入门到实战】十一、全文检索-ElasticSearch-
- 【ES从入门到实战】十三、全文检索-ElasticSearch-
接第15节
7)、term
和 match 一样。匹配某个属性的值。全文检索字段用 match,其他非 text 字段匹配用 term。
Avoid using the
termquery fortextfields.By default, Elasticsearch changes the values of
textfields as part of analysis. This can make finding exact matches fortextfield values difficult.To search
textfield values, use thematchquery instead.
非文本值使用 term 检索:
GET /bank/_search
{
"query": {
"term": {
"age":28
}
}
}
match 的 xxx.keyword,文本的精确匹配检索:
GET /bank/_search
{
"query": {
"match": {
"address.keyword": "789 Madison"
}
}
}
match 全文分词匹配:
GET /bank/_search
{
"query": {
"match": {
"address": "789 Madison"
}
}
}
match_phrase,将需要匹配的值当成一个整体单词(不分词)进行检索:
GET /bank/_search
{
"query": {
"match_phrase": {
"address": "789 Madison"
}
}
}
注意:如果对于文本值使用 term 检索时,并不会进行分词,而是精确检索,所以可能会匹配不到数据:
GET /bank/_search
{
"query": {
"term": {
"address": "789 Madison"
}
}
}
参考:






网友评论