分析分词
POST /bank/_analyze
{
"analyzer": "autoComplete",
"text": "杜克"
}
autoComplete 为我创建索引时自定义分词
用ik_max_word分词器分词
POST /_analyze
{
"analyzer": "ik_max_word",
"text": "杜克"
}
分词结果
{
"tokens" : [
{
"token" : "杜克",
"start_offset" : 0,
"end_offset" : 2,
"type" : "CN_WORD",
"position" : 0
}
]
}
看到是未分词成功的
默认使用standard标准分词器
POST /_analyze
{
"analyzer": "standard",
"text": "杜克"
}
可以分词
所以我在创建索引时自定义了分词器
"analysis":{
"analyzer":{
"autoComplete":{
"type":"custom",
"tokenizer":"standard",
"filter":["lowercase","autoCompleteFilter"]}},
"filter":{
"autoCompleteFilter":{
"type":"edgeNGram",
"min_gram":1,
"max_gram":50
}
}
}
用自定义分词 autoComplete 需要加上索引
POST /bank/_analyze
{
"analyzer": "autoComplete",
"text": "杜克"
}
是成功的