Elasticsearch
数据结构
- 数字类型
byte: 有符号的8位整数, 范围: [-128 ~ 127]
short: 有符号的16位整数, 范围: [-32768 ~ 32767]
integer: 有符号的32位整数, 范围: [-2^31 ~ 2^31-1]
long: 有符号的64位整数, 范围: [-2^63 ~ 2^63-1]
float: 32位单精度浮点数
double: 64位双精度浮点数
half_float: 16位半精度浮数
scaled_float: 缩放类型的的浮点数, 比如price字段只需精确到分, 57.34缩放因子为100, 存储结果为5734
- 字符串类型
{
"properties": {
"context": {
"type": "text",
"analyzer": "icu_analyzer"
}
}
}
{
"properties": {
"context": {
"type": "keyword"
}
}
}
- 日期类型
date: 格式化日期的字符串,代表时间毫秒数的长整型数字,
代表时间秒数的整数
- 布尔类型
- 二进制类型
- 范围类型
integer_range: [-2^31 ~ 2^31-1]
long_range: [-2^63 ~ 2^63-1]
float_range: 32位单精度浮点数
double_range: 64位双精度浮点数
date_range: 日期类型范围
ip_range: IP值的范围, 支持IPV4和IPV6, 或者这两种同时存在
- 其他类型
参考Elasticsearch的数据类型
数据操作
创建索引
api: /any_index
method: POST
body: json
{
"mappings": {
"dynamic": "false",
"properties": {
"title": {
"type": "text",
"analyzer": "icu_analyzer"
}
}
}
}
导入数据
api: /any_index/_bulk
method: POST
body: bulk file
{"index":{"_id":"1"}}
{"id": 1, "name": "123", "age": 3}
...