Elasticsearch

2020-07-16  本文已影响0人  黄海佳

基本

从ElasticSearch6.X开始,官方准备废弃Type了。对应数据库,对ElasticSearch的理解如下

常见数据类型
- 字符串:text,keyword
- 数据型:long,integer,short,byte,double,float,half_float,scaled_float
- 布尔:boolean
- 日期:date
- 二进制:binary
- 范围类型:integer_range,float_range,long_range,double_range,date_range

基本语法

PUT 方法
{
    "aliases": {},
    "mappings": {
      "doc": {
        "properties": {
          "delay": {
            "type": "float"
          },
          "localhost": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "message": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "remotehost": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "time": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "number_of_shards": "5",
        "number_of_replicas": "1"
      }
    }
}
image.png

参考

https://www.cnblogs.com/wwcom123/p/10410124.html
https://blog.csdn.net/laok186/article/details/89448169

上一篇 下一篇

猜你喜欢

热点阅读