目前有用到的用法如下:

 post /index_name/_search
{
"query" : {
"match_phrase": {
"nickname": {
"query": "nihao ma",
"slop" : 0
}
}
},
"size" : 10,
"from" : 0
}

通过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

05-11 20:18