elasticsearch关于字符串类型数据处理总结

1. 2.x版本的字符串数据设计mapping时可以设置成string类型的,如果需要不对字符串字段数据进行分词的话,

需要设置为不分析,只有string类型,通过设置是否分词区分是否分词,默认字符串设置成不分词。示例如下:

{

"mappings" : {

"products" : {

"properties" : {

"productID" : {

"type" : "string",

"index" : "not_analyzed"

}

}

}

}

}

2. 5.x以后版本将字符串存储对应的mapping数据类型分为了两种,具体是text和keyword,如果默认不进行分词需要设置成keyword。

具体设置示例如下:

{

"mappings" : {

"products" : {

"properties" : {

"productID" : {

"type" : "keyword",

//"type" : "text",

"index" : "not_analyzed"

}

}

}

}

}

你可能感兴趣的:(elasticsearch关于字符串类型数据处理总结)