Sorting ElasticSearch根据分数按字母顺序排序查询
是否可以通过更改索引设置或映射来选择按字母顺序对查询进行排序 我知道有一个“排序”查询,但它会删除分数,我希望除了按字母顺序排序的术语外,还考虑分数 例如,如果结果“A”和“Z”的分数为2,“C”的分数为1,我希望顺序为: A Z C 这可能吗 这是我当前的索引设置和映射:Sorting ElasticSearch根据分数按字母顺序排序查询,sorting,elasticsearch,indexing,Sorting,elasticsearch,Indexing,是否可以通过更改索引设置或映射来选择按字母顺序对查询进行排序 我知道有一个“排序”查询,但它会删除分数,我希望除了按字母顺序排序的术语外,还考虑分数 例如,如果结果“A”和“Z”的分数为2,“C”的分数为1,我希望顺序为: A Z C 这可能吗 这是我当前的索引设置和映射: { "users": { "settings": { "index": { "analysis": { "filter": {
{
"users": {
"settings": {
"index": {
"analysis": {
"filter": {
"shingle_filter": {
"max_shingle_size": "2",
"min_shingle_size": "2",
"output_unigrams": "true",
"type": "shingle"
},
"edgeNGram_filter": {
"type": "nGram",
"min_gram": "1",
"max_gram": "20"
}
},
"analyzer": {
"autocomplete_query_analyzer": {
"filter": [
"standard",
"asciifolding",
"lowercase"
],
"tokenizer": "standard"
},
"autocomplete_index_analyzer": {
"filter": [
"standard",
"asciifolding",
"lowercase",
"shingle_filter",
"edgeNGram_filter"
],
"tokenizer": "standard"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1"
}
}
}
}
{
"users": {
"mappings": {
"data": {
"properties": {
"name": {
"type": "string",
"analyzer": "autocomplete_index_analyzer",
"search_analyzer": "autocomplete_query_analyzer"
}
}
}
}
}
}
是否可以向索引设置中添加一些内容,以便按字母顺序对结果进行自动排序?ElasticSearch的文档显示,您应该能够按多个值进行排序,包括\u score
。尝试以下方法:
"sort": [
{ "date": { "order": "desc" }},
{ "_score": { "order": "desc" }}
]
我不确定您要按哪个字段排序,因此您需要根据需要调整上面的示例
让我知道这是否适用于您:)ElasticSearch的文档显示您应该能够按多个值进行排序,包括\u score
。尝试以下方法:
"sort": [
{ "date": { "order": "desc" }},
{ "_score": { "order": "desc" }}
]
我不确定您要按哪个字段排序,因此您需要根据需要调整上面的示例
让我知道这是否适用于您:)跟进,可能有一个假设,分数在排序中是隐式的,即您通过排序进行评分。跟进,可能有一个假设,分数在排序中是隐式的,即您通过排序进行评分。