elasticsearch 在搜索中默认使用索引排序
我正在使用ElasticSearch 7.6和6.0中引入的索引排序功能。 我想做的是在不指定排序的情况下执行
elasticsearch 在搜索中默认使用索引排序,
elasticsearch,lucene,
elasticsearch,Lucene,我正在使用ElasticSearch 7.6和6.0中引入的索引排序功能。 我想做的是在不指定排序的情况下执行GET/myindice/\u搜索,并根据我为索引而不是插入顺序指定的索引排序设置获取文档 我的索引根据文档: PUT twitter { "settings" : { "index" : { "sort.field" : "date", "sort.order" : "desc" } }
GET/myindice/\u搜索
,并根据我为索引而不是插入顺序指定的索引排序设置获取文档
我的索引根据文档:
PUT twitter
{
"settings" : {
"index" : {
"sort.field" : "date",
"sort.order" : "desc"
}
},
"mappings": {
"properties": {
"date": {
"type": "date"
}
}
}
}
PUT twitter/_doc/a
{
"date": "2015-01-01"
}
PUT twitter/_doc/b
{
"date": "2016-01-01"
}
PUT twitter/_doc/c
{
"date": "2017-01-01"
}
我最初的想法是
GET twitter/_search
应返回单据C、B和A。
我得到以下信息:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "twitter",
"_type" : "_doc",
"_id" : "a",
"_score" : 1.0,
"_source" : {
"date" : "2015-01-01"
}
},
{
"_index" : "twitter",
"_type" : "_doc",
"_id" : "b",
"_score" : 1.0,
"_source" : {
"date" : "2016-01-01"
}
},
{
"_index" : "twitter",
"_type" : "_doc",
"_id" : "c",
"_score" : 1.0,
"_source" : {
"date" : "2017-01-01"
}
}
]
}
}
由于文档对此特定主题不清楚,并且所有查询都使用排序:
是否需要在GET查询中指定排序顺序(从而重复指定为索引排序的排序)
提前感谢所有能帮助我的勤奋的灵魂