如果对一个string field进行排序,结果往往不准确,因为比如"test my elasticsearch "分词后是多个单词,再排序就不是我们想要的结果了
,有可能的出来的就是分词后某一个单词的评分高,导致排在前面。而我们是想"test my elasticsearch "整个字符串的搜索结果排在最前面。
PUT /website/article/1
{
"title": "first article",
"content": "this is my first article",
"post_date": "2017-01-01",
"author_id": 110
}
PUT /website/article/2
{
"title": "second article",
"content": "this is my second article",
"post_date": "2017-02-01",
"author_id": 110
}
PUT /website/article/3
{
"title": "third article",
"content": "this is my third article",
"post_date": "2017-03-01",
"author_id": 110
}
GET /website1/article/_search
{
"query": {
"match_all": {}
}
}