1. 2.x版本的字符串?dāng)?shù)據(jù)設(shè)計(jì)mapping時(shí)可以設(shè)置成string類型的,如果需要不對字符串字段數(shù)據(jù)進(jìn)行分詞的話,
需要設(shè)置為不分析,只有string類型,通過設(shè)置是否分詞區(qū)分是否分詞,默認(rèn)字符串設(shè)置成不分詞。示例如下:
{
"mappings" : {
"products" : {
"properties" : {
"productID" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}
2. 5.x以后版本將字符串存儲(chǔ)對應(yīng)的mapping數(shù)據(jù)類型分為了兩種,具體是text和keyword,如果默認(rèn)不進(jìn)行分詞需要設(shè)置成keyword。
具體設(shè)置示例如下:
{
"mappings" : {
"products" : {
"properties" : {
"productID" : {
"type" : "keyword",
//"type" : "text",
"index" : "not_analyzed"
}
}
}
}
}