一、数据类型
PUT /test_data_type
{
"mappings": {
"book" : {
"properties" : {
"id" : {"type": "long"}, //数字类型
"keyword" : {"type": "keyword"}, //字符串,精准匹配, 不能全文检索
"name" : {"type": "text"}, //字符串,可全文分词搜索,生成倒排索引
"date" : {"type" : "date"}, //日期
"type" : {"type" : "byte"}, //数字类型, -128 - 127
"num" : {"type" : "short"},
"price" : {
"type" : "scaled_float",
"scaling_factor": 100
},
"is_valid" : {"type" : "boolean"},//只接受 true/false/对应的字符串
"child_obj" : {"type" : "object"},//会有对象中元素扁平化导致的搜索问题
"child_nested" : {"type" : "nested"}, // 解决了对象中元素扁平化的问题
"price_range" : {"type" : "float_range"}//gte,lte
}
}
}
}