我使用命令:
在elasticsearch(v6)中创建了新索引curl -XPUT -H 'Content-Type: application/json' http://localhost:9200/sorttest -d '
{
"settings" : {
"index" : {
"sort.field" : ["username", "date"],
"sort.order" : ["asc", "desc"]
}
},
"mappings": {
"_doc": {
"properties": {
"username": {
"type": "keyword",
"doc_values": true
},
"date": {
"type": "date"
}
}
}
}
}
'
回应是
{"acknowledged":true,"shards_acknowledged":true,"index":"sorttest"}
接下来,我检查了生成的映射
curl -XGET localhost:9200/sorttest/_mapping?pretty
结果是
{
"sorttest" : {
"mappings" : {
"_doc" : {
"properties" : {
"date" : {
"type" : "date"
},
"username" : {
"type" : "keyword"
}
}
}
}
}
}
问题是:如何找出为我的索引设置的排序类型?
答案 0 :(得分:1)
只是
curl -XGET localhost:9200/sorttest?pretty
你会看到:
"settings" : {
"index" : {
...
"sort" : {
"field" : [
"username",
"date"
],
"order" : [
"asc",
"desc"
]
},
...
}
}