【ES从入门到实战】十一、全文检索-ElasticSearch-进阶-match全文检索

接第10节

3)、match【匹配查询】

  • 基本类型(非字符串),精确匹配

match 返回 account_number=20 的数据:

GET /bank/_search
{
    
    
  "query": {
    
    
    "match": {
    
    
      "account_number": 20
    }
  }
}

在这里插入图片描述

  • 字符串,全文检索

最终查询出 address 中包含 Kings 单词的所有记录,当搜索字符串类型的时候,会进行全文检索,并且每条记录有相关性得分。

GET /bank/_search
{
    
    
  "query": {
    
    
    "match": {
    
    
      "address": "Kings"
    }
  }
}

在这里插入图片描述

  • 字符串,多个单词(分词+全文检索)

全文检索按照评分进行排序,会对检索条件进行分词匹配

GET /bank/_search
{
    
    
  "query": {
    
    
    "match": {
    
    
      "address": "Mill Lane"
    }
  }
}

最终查询出 address 中包含 Mill 或者 Lane 或者 Mill Lane 的所有记录,并给出相关性得分
在这里插入图片描述

参考文档-query-dsl


参考:

Elasticsearch Reference

elastic

全文搜索引擎 Elasticsearch 入门教程

猜你喜欢

转载自blog.csdn.net/runewbie/article/details/106342547