你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
lmc
赞同来自:
PUT test_suggest { "mappings": { "name" : { "properties" : { "suggest" : { "type" : "completion", "analyzer": "ik_smart" } } } } } POST test_suggest/name { "suggest" : { "input": [ "阿里巴巴", "albb","alibaba" ], "weight" : 34 } } POST test_suggest/name { "suggest" : { "input": [ "百度", "bd","baidu" ], "weight" : 10 } }
POST test_suggest/name/_search?search_type=dfs_query_then_fetch { "suggest": { "my-suggest" : { "prefix" : "百度", "completion" : { "field" : "suggest", "size" : 50 , "fuzzy":{ "fuzziness":0 } } } } }
{ "took": 4, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 0, "max_score": 0, "hits": [] }, "suggest": { "my-suggest": [ { "text": "百度", "offset": 0, "length": 2, "options": [ { "text": "百度", "_index": "test_suggest", "_type": "name", "_id": "QRBe1GoBYDgG7DGxu69j", "_score": 60, "_source": { "suggest": { "input": [ "百度", "bd", "baidu" ], "weight": 10 } } } ] } ] } }
God_lockin
PUT xx/_doc/1 { "suggest": [ "Nevermind", "Nirvana" ] }
GET xx/_doc/_search { "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 1, "max_score": 1, "hits": [ { "_index": "music1", "_type": "_doc", "_id": "1", "_score": 1, "_source": { "suggest": [ "Nevermind", "Nirvana" ] } } ] } }
POST xx/_search { "suggest": { "song-suggest": { "prefix": "nir", "completion": { "field": "suggest" } } } } { "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 0, "max_score": 0, "hits": [] }, "suggest": { "song-suggest": [ { "text": "nir", "offset": 0, "length": 3, "options": [ { "text": "Nirvana", "_index": "music1", "_type": "_doc", "_id": "1", "_score": 1, "_source": { "suggest": [ "Nevermind", "Nirvana" ] } } ] } ] } }
lailai - 我一无所有
要回复问题请先登录或注册
3 个回复
lmc
赞同来自:
3.得到结果如下
我使用的版本是6.7, 主要是想问问 这个score跟这个weight是什么关系, 怎么计算的?谢谢!
另外我是通过将拼音、全拼、中文都放入input来实习通过拼音完成自动补全的,但这样无法应用在拼音中文混合的情况下,比如输入“百du”, 大家有什么建议吗? 关于中文、拼音混合情况下的自动补全
God_lockin
赞同来自:
你可以get出来看看,它的score或者说weight默认是1
所以在做后面的suggest的query的时候
lailai - 我一无所有
赞同来自:
英文:搜索词的字符个数 * 1 * weight (如果没有设置weight,则默认是1)