我刚打酱油去了,不好意思

使用match 怎么阻住中文分词

Elasticsearch | 作者 lwQAQ | 发布于2020年01月14日 | 阅读数:1167

GET /snail/_doc/_search
{
"query" : {
"match" : {
"conent":"'人国'.keyword"
}
}
}
结果:
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.5753642,
"hits" : [
{
"_index" : "snail",
"_type" : "_doc",
"_id" : "75tHmG8BmGR6OcAZouyJ",
"_score" : 0.5753642,
"_source" : {
"conent" : "我是中国人"
}
}
]
}

mapping:

{
"snail" : {
"mappings" : {
"properties" : {
"age" : {
"type" : "long"
},
"conent" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"content" : {
"type" : "text",
"index" : false,
"analyzer" : "ik_max_word"
},
"nickname" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"query" : {
"properties" : {
"query_string" : {
"properties" : {
"default_field" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"query" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
},
"title" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"username" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
已邀请:

lance_lin

赞同来自:

你是想content索引时使用ik_max_word但搜索时不需要?
可以在mappings定时search_analyzer,这样使用match时会使用search_analyzer定义的分析器

要回复问题请先登录注册