根据文档
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
preserve_position_increments = false应该使字符串中的连续关键字可搜索。但是对我来说,它不起作用。这是错误吗?在基巴纳州繁殖的步骤:
PUT /example-index/
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"_doc": {
"properties": {
"example-suggest-field": {
"type": "completion",
"analyzer": "stop",
"preserve_position_increments": false,
"max_input_length": 50
}
}
}
}
}
PUT /example-index/_doc/1
{
"example-suggest-field": [
{
"input": "Nevermind Nirvana",
"weight" : 10
}
]
}
POST /example-index/_search
{
"suggest": {
"bib-suggest" : {
"prefix" : "nir",
"completion" : {
"field" : "example-suggest-field"
}
}
}
}
POST /example-index/_search
{
"suggest": {
"bib-suggest" : {
"prefix" : "nev",
"completion" : {
"field" : "example-suggest-field"
}
}
}
}
如果是,我将报告错误
答案 0 :(得分:4)
这不是错误,preserve_position_increments
仅在删除停用词并且想要搜索停用词后的令牌时才有用(例如,搜索Beat
并找到The Beatles
) 。
在您的情况下,您可能应该改为索引["Nevermind", "Nirvana"]
,即标记数组。
如果您尝试为"The Nirvana"
编制索引,则可以通过搜索nir