我具有以下设置和分析器:
{
"settings":{
"index":{
"analysis":{
"analyzer":{
"edge_ngram_analyzer":{
"filter":[
"lowercase"
],
"tokenizer":"edge_ngram_tokenizer"
},
"edge_ngram_search_analyzer":{
"tokenizer":"lowercase"
}
},
"tokenizer":{
"edge_ngram_tokenizer":{
"type":"edge_ngram",
"min_gram":4,
"max_gram":200,
"token_chars":[
"letter"
]
}
}
}
}
},
"mappings":{
"local_organization":{
"properties":{
"autocomplete":{
"type":"text",
"index":true,
"analyzer":"edge_ngram_analyzer",
"search_analyzer":"edge_ngram_search_analyzer"
}
}
}
}
}
我将以下数据发布到其中:
{
"autocomplete": "Service Provider test 1"
}
{
"autocomplete": "Service Provider test modification 2506"
}
{
"autocomplete": "Service Provider organisation 1"
}
{
"autocomplete": "Service Provider organisation 2"
}
这是我的查询:
{
"query": {
"match": {
"autocomplete": "serv test"
}
}
}
我得到了这个结果:
"hits": {
"total": 1,
"max_score": 1.6256903,
"hits": [
{
"_index": "local_organization",
"_type": "local_organization",
"_id": "1002",
"_score": 1.6256903,
"_source": {
"autocomplete": "Service Provider organisation 2"
}
},
{
"_index": "local_organization",
"_type": "local_organization",
"_id": "176",
"_score": 1.5223445,
"_source": {
"autocomplete": "Service Provider test 1"
}
},
{
"_index": "local_organization",
"_type": "local_organization",
"_id": "175",
"_score": 1.4965906,
"_source": {
"autocomplete": "Service Provider test modification 2506"
}
},
{
"_index": "local_organization",
"_type": "local_organization",
"_id": "177",
"_score": 1.4096531,
"_source": {
"autocomplete": "Service Provider organisation 1"
}
}
]
}
有人可以向我解释如何根据自动完成字段获得排序结果。这意味着,当我输入“服务测试”时,我必须按该顺序获取结果