专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

ES实战十六、全文检索-ElasticSearch-进阶-term查询

接第15节

8)、term

和 match 一样。匹配某个属性的值。全文检索字段用 match,其他非 text 字段匹配用 term

Avoid using the term query for text fields.

By default, Elasticsearch changes the values of text fields as part of analysis. This can make finding exact matches for text field values difficult.

To search text field values, use the match query instead.

非文本值使用 term 检索:

GET /bank/_search
{
  "query": {
    "term": {
      "age":28
    }
  }
}

75_1.png

match 的 xxx.keyword,文本的精确匹配检索:

GET /bank/_search
{
  "query": {
    "match": {
      "address.keyword": "789 Madison"
    }
  }
}

75_2.png

match 全文分词匹配:

GET /bank/_search
{
  "query": {
    "match": {
      "address": "789 Madison"
    }
  }
}

75_3.png

match_phrase,将需要匹配的值当成一个整体单词(不分词)进行检索:

GET /bank/_search
{
  "query": {
    "match_phrase": {
      "address": "789 Madison"
    }
  }
}

75_4.png

注意:如果对于文本值使用 term 检索时,并不会进行分词,而是精确检索,所以可能会匹配不到数据:

GET /bank/_search
{
  "query": {
    "term": {
      "address": "789 Madison"
    }
  }
}

75_5.png

参考文档-query-dsl-term-query

参考文档-query-dsl


参考:

Elasticsearch Reference

elastic

全文搜索引擎 Elasticsearch 入门教程

文章永久链接:https://tech.souyunku.com/37507

未经允许不得转载:搜云库技术团队 » ES实战十六、全文检索-ElasticSearch-进阶-term查询

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们