Elasticsearch match_phrase用法

目前有用到的用法如下:

 1 post /index_name/_search
 2 {
 3   "query" : {
 4     "match_phrase": {
 5       "nickname": {
 6         "query": "nihao ma",
 7         "slop" : 0
 8       }
 9     }
10   },
11   "size" : 10,
12   "from" : 0
13 }

通过from+size来实现分页,但是有个限制,from+size不能超过index.max_result_window。

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html

slop参数其实就是你允许你输入的词里面中间还能隔着几个词。也就是说,slop=0就是只能按你输入的词来搜索。slop=1,比如输入是“ni ma", 那么结果里可能就包含"ni ba ma"。

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html

 

posted @ 2018-10-19 11:33  linyx  阅读(947)  评论(0编辑  收藏  举报