一个字符串字段 需要同时支持模糊匹配和精准匹配,也就是说两种分词类型1、keyword,2、ik_分词 ,
{
"testkeyword": {
"properties": {
"Name": {
"type": "string",
"fields": {
"text": {
"search_analyzer": "ik_smart",
"analyzer": "ik_max_word",
"type": "text",
"index_options": "offsets"
},
"keyword": {
"type": "keyword"
}
}
}
}
}
}
{
"testkeyword": {
"properties": {
"Name": {
"type": "string",
"fields": {
"text": {
"search_analyzer": "ik_smart",
"analyzer": "ik_max_word",
"type": "text",
"index_options": "offsets"
},
"keyword": {
"type": "keyword"
}
}
}
}
}
}
3 个回复
TinaZhou
赞同来自:
God_lockin
赞同来自:
waywu
赞同来自:
PUT testindex
{
"mappings": {
"properties": {
"name": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}