elastic search字段类型

1.type

string
索引分析(index):analyzed(默认)、not_analyzed、no

存储(store): true(独立存储)、false(默认)不存储。

Numeric
包括 long、integer、short、byte等·
索引分析(index):not_analyzed(默认)、no
存储:同string

date
日期类型
索引分析(index):not_analyzed(默认)、no
存储(store): true(独立存储)、false(不存储默认)
格式化(format): 解析日期格式

	"date": {
  "type":   "date",
  "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}

时间表达式

nested vs Object

nested(嵌套类型):构造数组,里面有多个为json格式的嵌套对象,保持每个嵌套的对象的内容相关联

Object(内部对象默认):被扁平化处理,字段 之间的相关性已经丢失了,因为每个多值域只是一包无序的值,而不是有序数组。
例:
nest结构:
在这里插入图片描述
这里的stable_ts为nested结构,weekdays和times相关联,绑定在一起。

Object结构:

{
    "followers.age":    [19, 26, 35],
    "followers.name":   [alex, jones, lisa, smith, mary, white]
}

age与name没有绑定一起。

Text vs keyword
Text:会分词,然后进行索引

   支持模糊、精确查询
   不支持聚合

keyword:不进行分词,直接索引

   支持模糊、精确查询
   支持聚合

2. index

analyzed:
利用解析器,一般在string中用到,比如分词,然后索引

not_analyzed:
不采用任何解析器,精确索引

no:
不索引

例:
在这里插入图片描述
3.analyzer

standard: 默认分词器。
whitespacce: 空格为分隔符
simple: 空格,标点符号,数字作为分割符
stop: 分词使用默认stopwords(english)
keyword: 不分词
例:
在这里插入图片描述

POST _analyze
{
  "analyzer": "standard",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

返回:

{
  "tokens": [
    {
      "token": "the",
      "start_offset": 0,
      "end_offset": 3,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "2",
      "start_offset": 4,
      "end_offset": 5,
      "type": "<NUM>",
      "position": 1
    },
    {
      "token": "quick",
      "start_offset": 6,
      "end_offset": 11,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "brown",
      "start_offset": 12,
      "end_offset": 17,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "foxes",
      "start_offset": 18,
      "end_offset": 23,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "jumped",
      "start_offset": 24,
      "end_offset": 30,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "over",
      "start_offset": 31,
      "end_offset": 35,
      "type": "<ALPHANUM>",
      "position": 6
    },
    {
      "token": "the",
      "start_offset": 36,
      "end_offset": 39,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "lazy",
      "start_offset": 40,
      "end_offset": 44,
      "type": "<ALPHANUM>",
      "position": 8
    },
    {
      "token": "dog's",
      "start_offset": 45,
      "end_offset": 50,
      "type": "<ALPHANUM>",
      "position": 9
    },
    {
      "token": "bone",
      "start_offset": 51,
      "end_offset": 55,
      "type": "<ALPHANUM>",
      "position": 10
    }
  ]
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值