目前我正在学习,仍然是Elasticsearch的新手。
我尝试创建一个包含多个排序字段(id,created_at)的索引。我的计划是尝试在Python Elasticsearch Client的search函数中使用search_after参数。
下面是我已经尝试过的查询:
PUT /my-index
{
"settings": {
"index":[
{
"sort.field": "created_at",
"sort.order": "asc"
},
{
"sort.field": "id",
"sort.order": "asc"
}
]
},
"mappings": {
"properties": {
"id": {
"type": "keyword",
"doc_values": true
},
"name": {
"type": "keyword"
},
"created_at": {
"type": "date"
}
}
}
}
但是,我得到了这样的错误:
{
"error" : {
"root_cause" : [
{
"type" : "settings_exception",
"reason" : "Failed to load settings from [{\"index\":[{\"sort.field\":\"created_at\",\"sort.order\":\"asc\"},{\"sort.field\":\"id\",\"sort.order\":\"asc\"}]}]"
}
],
"type" : "settings_exception",
"reason" : "Failed to load settings from [{\"index\":[{\"sort.field\":\"created_at\",\"sort.order\":\"asc\"},{\"sort.field\":\"id\",\"sort.order\":\"asc\"}]}]",
"caused_by" : {
"type" : "illegal_state_exception",
"reason" : "only value lists are allowed in serialized settings"
}
},
"status" : 500
}
请帮助我。提前感谢!
2条答案
按热度按时间xxslljrj1#
你需要这样做:
56lgkhnf2#
你有一个语法错误,弹性不知道组合排序顺序。请尝试以下操作,