【发布时间】:2023-03-10 17:58:01
【问题描述】:
我正在尝试进行搜索并对结果进行排序。但是,我收到一个错误,不知道为什么。
编辑 - 我将提供我的完整映射。
"myindex": {
"mappings": {
"mytype": {
"dynamic_templates": [
{
// Dynamic templates here!
}
],
"properties": {
"fieldid": {
"type": "keyword",
"store": true
},
"fields": {
"properties": {
"myfield": {
"type": "text",
"fields": {
"sort": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "myanalyzer"
}
}
},
"isDirty": {
"type": "boolean"
}
}
}
}
}
}
当我使用排序执行搜索时,如下所示:
POST /index/_search
{
"sort": [
{ "myfield.sort" : {"order" : "asc"}}
]
}
我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "No mapping found for [myfield.sort] in order to sort on",
"index_uuid": "VxyKnppiRJCrrnXfaGAEfA",
"index": "index"
}
]
"status": 400
}
我正在关注有关 elasticsearch 的文档。 DOCUMENTATION
我也检查了这个链接: DOCUMENTATION
有人可以帮我吗?
【问题讨论】:
-
拨打
curl -XGET localhost:9200/index会得到什么? -
我得到了映射。但问题不在于映射,而在于搜索。您可以在最后一条评论中查看解决方案。无论如何谢谢:)
标签: sorting elasticsearch nest elasticsearch-5