Sorting 弹性搜索:如果字段日期设置为true,则文本排序不起作用
我试图对一个文本类型的字段进行排序,我将fielddate设置为true,但它总是给出相同的顺序 这是我的映射:Sorting 弹性搜索:如果字段日期设置为true,则文本排序不起作用,sorting,
elasticsearch,Sorting,
elasticsearch,我试图对一个文本类型的字段进行排序,我将fielddate设置为true,但它总是给出相同的顺序 这是我的映射: "movieTitle": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 }
"movieTitle": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "french",
"fielddata": true
}
这是我的要求
POST /0802v6/movie/_search
{
"from": 0,
"size": 10,
"min_score": 1,
"sort": [
{
"movieTitle": {
"order": "asc" //or desc
}
}
],
"_source": "movieTitle",
"query": {...}
}
不幸的是,无论我设置asc还是desc,结果都是一样的。
我可以看到sort属性不包含正确的单词
"hits": [ {
"_index": "0802v6",
"_type": "proj",
"_id": "AVojCSjg8N13TOVDp6r2",
"_score": null,
"_source": {
"movieTitle": "12 Years a Slave"
},
"sort": [
"12"
]
},
{
"_index": "0802v6",
"_type": "proj",
"_id": "AVojCSg58N13TOVDp6pV",
"_score": null,
"_source": {
"movieTitle": "black wing has my angel"
},
"sort": [
"angel"
]
},
{
"_index": "0802v6",
"_type": "proj",
"_id": "AVojCSjg8N13TOVDp6qT",
"_score": null,
"_source": {
"movieTitle": "TO DO LIST (THE)"
},
"sort": [
"do"
]
},
{
"_index": "0802v6",
"_type": "proj",
"_id": "AVojCSo28N13TOVDp68w",
"_score": null,
"_source": {
"movieTitle": "Third Person"
},
"sort": [
"person"
]
}
]
你知道会发生什么事以及如何解决它吗?这是因为标题被标记为单词。因此,像《塞尔达的土豚》这样的电影片名仍然会因为“土豚”这个词而提前排序。您可能希望保留文本字段以供搜索,因此您应该查看多个字段,并按
原始
(或您命名的任何内容)进行排序,如下所示:
"sort": {
"movieTitle.raw": "asc"
},
您仍然需要movieTitle
字段进行全文搜索
有关多字段文档,请参见