elasticsearch-analyzer-pinyin + ik 一起使用没有效果
Elasticsearch | 作者 hnj1575565068 | 发布于2018年04月19日 | 阅读数:3149
PUT country
{
"index": {
"analysis": {
"analyzer": {
"ik_pinyin_analyzer": {
"type": "custom",
"tokenizer": "ik_smart",
"filter": ["my_pinyin", "word_delimiter"]
}
},
"filter": {
"my_pinyin": {
"type": "pinyin",
"keep_separate_first_letter" : false,
"keep_full_pinyin" : true,
"keep_original" : true,
"limit_first_letter_length" : 16,
"lowercase" : true,
"remove_duplicated_term" : true
}
}
}
}
}
PUT country/items/_mapping
{
"items":{
"properties":{
"name":{
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "ik_pinyin_analyzer"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
POST _bulk
{"index":{"_index":"country","_type": "item","_id": 1}}
{"name": "美国"}
{"index":{"_index":"country","_type": "item","_id": 2}}
{"name": "英国"}
{"index":{"_index":"country","_type": "item","_id": 3}}
{"name": "中国"}
{"index":{"_index":"country","_type": "item","_id": 4}}
{"name": "中华人民共和国"}
{"index":{"_index":"country","_type": "item","_id": 5}}
{"name": "gongheguo"}
GET country/_search
{
"query": {
"match": {
"name.pinyin": "guo"
}
}
}
结果:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
我这配置有问题吗?
{
"index": {
"analysis": {
"analyzer": {
"ik_pinyin_analyzer": {
"type": "custom",
"tokenizer": "ik_smart",
"filter": ["my_pinyin", "word_delimiter"]
}
},
"filter": {
"my_pinyin": {
"type": "pinyin",
"keep_separate_first_letter" : false,
"keep_full_pinyin" : true,
"keep_original" : true,
"limit_first_letter_length" : 16,
"lowercase" : true,
"remove_duplicated_term" : true
}
}
}
}
}
PUT country/items/_mapping
{
"items":{
"properties":{
"name":{
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart",
"fields": {
"pinyin": {
"type": "text",
"analyzer": "ik_pinyin_analyzer"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
POST _bulk
{"index":{"_index":"country","_type": "item","_id": 1}}
{"name": "美国"}
{"index":{"_index":"country","_type": "item","_id": 2}}
{"name": "英国"}
{"index":{"_index":"country","_type": "item","_id": 3}}
{"name": "中国"}
{"index":{"_index":"country","_type": "item","_id": 4}}
{"name": "中华人民共和国"}
{"index":{"_index":"country","_type": "item","_id": 5}}
{"name": "gongheguo"}
GET country/_search
{
"query": {
"match": {
"name.pinyin": "guo"
}
}
}
结果:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
我这配置有问题吗?
0 个回复