ES权威指南[官方文档学习笔记]-13 full-text search

es:http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_full_text_search.html

下一篇博客:http://my.oschina.net/qiangzigege/blog/263764

内容:

全文搜索,牛逼之处。

GET /megacorp/employee/_search
{
    "query" : {
        "match" : {
            "about" : "rock climbing"
        }
    }
}

返回2个文档。

{
   ...
   "hits": {
      "total":      2,
      "max_score":  0.16273327,
      "hits": [
         {
            ...
            "_score":         0.16273327, 
            "_source": {
               "first_name":  "John",
               "last_name":   "Smith",
               "age":         25,
               "about":       "I love to go rock climbing",
               "interests": [ "sports", "music" ]
            }
         },
         {
            ...
            "_score":         0.016878016, 
            "_source": {
               "first_name":  "Jane",
               "last_name":   "Smith",
               "age":         32,
               "about":       "I like to collect rock albums",
               "interests": [ "music" ]
            }
         }
      ]
   }
}

默认的,es按照相关分数排序,也就是说,按照匹配度来排序。

为什么Jane Smith也作为结果返回? 因为包含了rock字段。

一个好的例子来说明:ES如何做全文搜索,相关性的思想对es非常重要,跟传统数据库不同之处。


 

你可能感兴趣的:(elasticsearch)