elasticsearch 数据类型

参考

aggregate_metric_double:预聚合指标值

字段有4个子字段 min, max, sum, value_count来分别存储double数值,专做聚合使用

  • metrics: [ “min”, “max”, “sum”, “value_count” ]指标功能 对应聚合中的各项
  • default_metric: 设置默认指标功能
  • min所有min指标字段的最小值
  • max所有max指标字段的最大值
  • sum:所有sum指标的总和
  • value_count:所有value_count指标的总和
  • avg:sum的总和除以value_count总和
DELETE myindex
PUT myindex
{
  "mappings": {
    "properties": {
      "aggField": {
        "type": "aggregate_metric_double",
        "metrics": [ "min", "max", "sum", "value_count" ],
        "default_metric": "max"
      }
    }
  }
}
PUT myindex/_doc/1
{
  "aggField":{
    "min":1,
    "max":100,
    "sum":46,
    "value_count":21
  }
}
PUT myindex/_doc/2
{
  "aggField":{
    "min":12,
    "max":1000,
    "sum":460,
    "value_count":221
  }
}

# 根据指标进行聚合
GET myindex/_search
{
  "size":0,
  "aggs": {
    "aggsMin": {
      "min": {"field": "aggField"}
    },
    "aggsMax": {
      "max": {"field": "aggField"}
    },
    "aggsSum": {
      "sum": {"field": "aggField"}
    },
    "aggsVCount": {
      "value_count": {"field": "aggField"}
    },
    "aggsAgv": {
      "avg": {"field": "aggField"}
    }
  }
}

# 使用默认指标查询 最大值=1000
GET myindex/_search
{
  "query": {
    "term": {
      "aggField": {
        "value": "1000"
      }
    }
  }
}

binary 二进制

二进制值编码为Base64字符串。

PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "binary":{
         "type":"binary"
       }
    }
  }
}
POST es_field_type/_doc
{
  "binary":"U29tZSBiaW5hcnkgYmxvYg=="
}

boolean 布尔

true和false。

keyword 整词

字符串不可被分词,查询速度快

wildcard 整词匹配

通配符字段类型是一个专门的关键字字段,用于您计划使用类似grep的通配符和regexp查询搜索的非结构化机器生成的内容。

#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"wildcard"
       }
    }
  }
}

POST es_field_type/_doc
{
  "fieldName":"keyword"
}

GET es_field_type/_search
{
  "query": {
    "wildcard": {
      "fieldName": {
        "value": "*yw*"
      }
    }
  }
}

constant_keyword 常量词

设置 常量值,不可修改
如果不设置value,将第一次插入的值作为常量

#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"keyword"
       },
       "level": {
        "type": "constant_keyword",
        "value": "debug"//如果不设置value,将第一次插入的值作为常量
      }
    }
  }
}

在level设置了debug后,在插入数据level必须等于debug,不然会报错误
"[constant_keyword] field [level] only accepts values that are equal to the value defined in the mappings [debug], but got [info]"

Number 数值

  • long
  • integer
  • short
  • byte
  • double
  • float

date 日期

日期格式可以自定义,但如果没有指定格式,则使用默认格式:

"strict_date_optional_time||epoch_millis"

可以使用||分隔多个格式 作为分隔符。 将依次尝试每种格式,直到找到匹配的格式。 第一个格式将用于将从时间的毫秒转换为字符串。
format格式化

alias 别名

  • 必须是一个具体的字段,不是一个对象或另一个字段别名。
  • 目标字段必须已经存在。
  • 如果定义了嵌套对象,则字段别名必须具有与其目标相同的嵌套作用域。
  • 一个字段别名只能有一个目标。
  • 不能插入数据
  • 不能 在"_source"中使用
#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"text"
       },
       "str":{
         "type": "alias",//指定别名类型
         "path": "fieldName" //指定别名来源(必须存在)
       }
    }
  }
}

POST es_field_type/_doc
{
  "fieldName":"2015-01-01"
}

GET es_field_type/_search
{
  "query": {
    "match": {
      "str": "2015"
    }
  }
}

object 格式类型

这种格式主要是在建立mapping式使用properties进行嵌套,插入时按照对象名称使用json方式插入即可
在这里插入图片描述

PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"text"
       },
       "obj":{
          "properties": {
            "name":{
              "type":"text"
            },
            "age":{
              "type":"integer"
            }
          }
       }
    }
  }
}

POST es_field_type/_doc
{
  "fieldName":"2015-01-01",
  "obj":{
    "name":"zhangsan",
    "age":14
  }
}

flattened (自由JSON)

目前,flattened的对象字段可以与以下查询类型一起使用:

  • term, terms, and terms_set
  • prefix
  • range
  • match and multi_match
  • query_string and simple_query_string
  • exists
#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"flattened"
       }
    }
  }
}

POST es_field_type/_doc
{
  "fieldName":{
    "name":"zhangsan",
    "age":15
  }
}

GET es_field_type/_search
#查询方法1  直接按值查询
GET es_field_type/_search
{
  "query": {
    "term": {
      "fieldName": {
        "value": "zhangsan"
      }
    }
  }
}
#查询方法2  直接嵌套字段查询
GET es_field_type/_search
{
  "query": {
    "term": {
      "fieldName.name": {
        "value": "zhangsan"
      }
    }
  }
}


nested 嵌套类型

index.mapping.nested_fields.limit
索引中不同嵌套映射的最大数目。嵌套类型只应在特殊情况下使用,即需要相互独立地查询对象数组。为了防止设计不良的映射,该设置限制了每个索引唯一嵌套类型的数量。默认是50。
在前面的例子中,对于这个限制,用户映射将只算作1。

index.mapping.nested_objects.limit
单个文档可以包含所有嵌套类型的嵌套JSON对象的最大数量。当文档包含太多嵌套对象时,此限制有助于防止内存不足错误。默认是10000。

#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"nested"//不设置对象内容是无法使用聚合的
       },
       "student":{
         "type":"nested",
         "properties": {
           "name":{"type":"keyword"},
           "age":{"type":"integer"}
         }
       }
    }
  }
}

POST es_field_type/_doc
{
  "fieldName":{
    "title":"qweert",
    "type":"OA"
  },
  "student":[
    {"name" : "张三","age":15},
    {"name" : "李四","age":18}
  ]
}

GET es_field_type/_search
#查询方法
GET es_field_type/_search
{
  "query": {
    "nested": {
      "path": "student",
      "query": {
        "match": {
          "student.name": "张三"
        }
      },
      "inner_hits": {//可以高亮匹配的嵌套文档
        "highlight": {}
      }
    }
  }
}

GET es_field_type/_search
{
  "size":0,
  "aggs": {
    "aggName": {
      "nested": {
        "path": "student"
      },
      "aggs":{//aggs是在aggName内
        "aggname1":{
          "terms": {
            "field": "student.name"
          }
        }
      }
    }
    
  }
}
#刪除數據
POST es_field_type/_doc/1/_update
{
  "script":{
    "lang": "painless",
    "source": """
      ctx._source.student.removeIf(it->it.name=="张三")
    """
  }
}

#增加数据
POST es_field_type/_doc/1/_update
{
  "script":{
    "lang": "painless",
    "source": """
      ctx._source.student.add(params.obj)
    """,
    "params": {
      "obj":{
        "name":"王5",
        "age":555
      }
    }
  }
}

#修改数据
POST es_field_type/_doc/1/_update
{
  "script":{
    "source": """
     for(e in ctx._source.student){
       if(e.name=="李四"){
         e.age=999
       }
     }
    """
  }
}


join 文档父子关系

Join可以让我们创建parent/child关系

如果你的数据需要频繁的更新,并带来性能上的影响,这个时候,join数据类型可能是你的一个解决方案。

join数据类型可以完全地把两个object分开,但是还是保持这两者之前的关系。

  • parent及child是完全分开的两个文档
  • parent可以单独更新而不需要重新reindex child
  • children可以任意被添加/串改/删除而不影响parent及其它的children

创建索引

relations中我们规定了水果为父文档,子文档为["苹果","香蕉","火龙果","橙子"],
并且相当于规范了子文当的范围

#创建mapping
PUT /es_field_type?pretty=true
{
  "settings": {
    "number_of_replicas": 2,
    "number_of_shards": 2
  }, 
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"join",
          "relations":{
            "水果":["苹果","香蕉","火龙果","橙子"]
          }
       },
       "idx":{
         "type":"integer"
       }
    }
  }
}

routing是强制性的,因为父文件和子文件必须在相同的分片上建立索引。与 "paren"1"相对应
指定此子文档的父文档ID:1。

#定义父文档
POST es_field_type/_bulk?refresh
{ "index":  { "_index": "es_field_type","_id":"1"}}
{"fieldName":{"name":"水果"},"idx":1}
{ "index":  { "_index": "es_field_type","_id":"2"}}
{"fieldName":{"name":"水果"},"idx":2}
#创建子文档
POST es_field_type/_bulk?routing=1
{ "index":  { "_index": "es_field_type","_id":"3"}}
{"fieldName":{"name":"苹果","parent":"1"},"idx":3}
{ "index":  { "_index": "es_field_type","_id":"4"}}
{"fieldName":{"name":"香蕉","parent":"1"},"idx":4}
{ "index":  { "_index": "es_field_type","_id":"5"}}
{"fieldName":{"name":"火龙果","parent":"1"},"idx":5}
{ "index":  { "_index": "es_field_type","_id":"6"}}
{"fieldName":{"name":"西柚","parent":"1"},"idx":6}

这里子文当必须是父文档内的数据,不然会报错
"unknown join name [西柚] for field [fieldName]"

has_child 查询

#通过子文档查父文档
GET es_field_type/_search
{
  "query": {
    "has_child": {
      "type": ["西柚","苹果","香蕉"],//子文档名称
      "ignore_unmapped":true,//忽略未映射的子文档,不报错,来查询不存在的类型
      "query": {//筛选条件
        "match_all": {}
      }
    }
  }
}
  • max_children: 为返回的父文档匹配查询的最大子文档数。如果父文档超过这个限制,它将被排除在搜索结果之外。
  • min_children: 匹配查询以匹配返回的父文档的查询所需的最小子文档数。如果父文档不满足此限制,则将其从搜索结果中排除。
  • score_mode :指示匹配子文档的得分如何影响根父文档的相关性得分。有效值:
    • none (Default)
    • avg
    • min
    • sum

has_parent

# 通过父文档查询子文档
GET es_field_type/_search
{
  "query": {
    "has_parent": {
      "parent_type": "水果",
      "query": {
        "match_all": {}
      }
    }
  }
}

parent_id

# 根据子文档查询指定id的父文档
GET es_field_type/_search
{
  "query": {
    "parent_id":{
      "type":"火龙果",//子文档
      "id":"1",//父文档id,
      "ignore_unmapped":false//查询西柚忽略错误
    }
  }
}

children 聚合

# children 聚合函数 统父文档
GET es_field_type/_search
{
  "size":0,
  "aggs": {
    "testAggs": {
      "children": {//使用的聚合函数
        "type": "苹果"  //子文档
      },
      "aggs": { //children同级
        "NAME": {
          "terms": {
            "field": "idx",
            "size": 10
          }
        }
      }
    }
  }
}
# 聚合函数方式 统父文档
GET es_field_type/_search
{
  "size":0,
  "aggs": {
     "testAggs":{
        "terms": {
          "field": "fieldName#水果",
          "size": 10
        }
     }
  }
}

Range

integer_range32位有符号整型数范围。最小值是-231,最大值是231-1。
float_range单精度32位IEEE 754浮点值范围。
long_range64位有符号整型数范围。最小值是-263,最大值是263-1。
double_range双精度64位IEEE 754浮点值范围。
date_range以系统纪元经过的无符号64位整数毫秒表示的日期值范围。
ip_range支持IPv4或IPv6(或混合)地址的ip值范围。

range字段接受一下参数:

coerce尝试将字符串转换为数字并截断整数的分数。 接受true(默认)和false。
boost映射字段级查询时间提升。 接受一个浮点数,默认为1.0。
include_in_all字段值是否应包含在**_all字段中? 接受true或者false**。 如果index设置为false,或者如果父对象字段将include_in_all设置为false,则默认为false。 否则默认为true。
index应该可以搜索该字段吗? 接受true(默认)和false。
store字段值是否应与**_source字段分开存储和检索。 接受true或false**(默认)。
#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "date_range":{  
         "type":"date_range",
         "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
       },
       "integer_range":{
         "type":"integer_range"
       }
    }
  }
}
#插入
POST es_field_type/_doc
{
  "date_range":{
    "gte":"2020-12-31",
    "lte":"2021-12-31"
  },
  "integer_range":{
    "gte":0,
    "lte":20
  }
}

#查询
GET es_field_type/_search
{
  "query": {
    "term": {
      "integer_range": {
        "value": 5
      }
    }
  }
}

ip

ip字段可以索引/存储IPv4或IPv6地址。

#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
        "ipaddr":{
          "type": "ip",
          "ignore_malformed":false
        }
    }
  }
}
#插入
POST es_field_type/_doc
{
  "ipaddr":"192.168.1.1"
}

#查询
GET es_field_type/_search
{
  "query": {
    "term": {
      "ipaddr": {
        "value": "192.168.1.1"
      }
    }
  }
}

version 软件版本

版本字段类型是关键字字段的专门化,用于处理软件版本值并支持它们的专门化优先规则。
(例如:“2.1.0”<“2.4.1”<“2.11.2”)和预发布版本在发布版本之前排序(即:<“1.0.0-alpha 1.0.0”)。
在“1.0.0”和“1.5.0”之间的范围查询将包括“1.2.3”版本,但不包括“1.11.2”。请注意,当使用按字母排序的常规关键字字段进行索引时,情况会有所不同。
字段参数
1.11.0>1.9.0

#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
        "fieldName":{
          "type": "version"
        }
    }
  }
}
#插入
POST es_field_type/_bulk
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"0.0.1"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.0.0"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.1.1"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.5.1"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.5.56"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.5.99"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.9.0"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.9.13"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.11.0"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"1.11.2"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"2.0.0"}
{ "index":  { "_index": "es_field_type"}}
{"fieldName":"2.1.0"}


#查询
GET es_field_type/_search
{
  "query": {
    "range": {
      "fieldName": {
        "gte": "1.6.0",
        "lte": "1.11.2"
      }
    }
  }
}

text 文本类型

text字段不用于排序,不可用于脚本不可聚合
聚合需要开启fielddata=true但增加内存,聚合适合keyword
不开启fielddata可以使用 fields属性来实现

  • analyzer:做分词然后插入倒排索引,此时就可能用到analyzer指定的分词器
  • search_analyzer:在查询时,先对要查询的text类型的输入做分词,再去倒排索引搜索,此时就可能用到search_analyzer指定的分词器
  • search_quote_analyzer:设置允许您为短语指定一个分析器,这在处理禁用短语查询的停止词时特别有用。
  • index_prefixes: 参数允许对词汇前缀进行索引,以加速前缀搜索。
    • min_chars :索引的最小前缀长度。必须大于0,默认值为2。该值是包含的。
    • max_chars:索引的最大前缀长度。必须小于20,默认值为5。该值是包含的。

completion 自动补全(配合suggest)

PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
        "fieldName":{
          "type": "completion",
          "analyzer":"ik_smart"
        }
    }
  }
}
  • analyzer: 索引分词器
  • search_analyzer:要使用的搜索分析器,默认为分析器的值。
  • preserve_separators:保留分隔符,默认为true。
  • max_input_length:限制单个输入的长度,默认为50个UTF-16代码点。这个限制只在索引时使用,以减少每个输入字符串的总字符数,以防止大量输入使底层数据结构膨胀。大多数用例不会受到默认值的影响,因为前缀补全很少超过超过几个字符的前缀。

使用suggest查询

#插入
POST es_field_type/_doc
{
  "fieldName":[{"input":"薄荷健康","weight":1}]
}
POST es_field_type/_doc
{
  "fieldName":[{"input":"薄荷健康2","weight":10}]
}


POST es_field_type/_search?pretty
{
  "_source": "fieldName", //减少网络开销
  "suggest": {
    "YOUR_SUGGESTION": {
      "prefix": "薄荷", //前缀       
      "completion": {         
          "field": "fieldName" ,
          "size":"5",
          "skip_duplicates": true,//是否应该过滤重复的建议,
          "fuzzy": {  
            "fuzziness": 60 //模糊系数
          }
      }
    }
  }
}

参数

boost

在查询时间,单个字段可以被自动提升——计算更多的相关度得分

doc_values

该字段是否存储在磁盘上,以便以后用于排序、聚合或脚本编写?接受true(默认)或false。

index

索引选项控制字段值是否被搜索到。默认值为true。没有索引的字段是不可查询的。

null_value

不能索引或搜索空值。当一个字段被设置为null(或一个空数组或一个空值数组)时,它被视为该字段没有值。数值类型不可以

{
  "mappings": {
    "properties": {
      "status_code": {
        "type":       "keyword",
        "null_value": "NULL" 
      }
    }
  }
}

写入数据时可以设置为null
"status_code": null

空数组不视为null
"status_code": []

可查询为null的数据

"query": {
    "term": {
      "status_code": "NULL" 
    }
  }

exists查的是存在这个字段,而null_val 感觉实际上和写入null字符串没区别

GET es_field_type/_search
{
    "query": {
      "exists": {
        "field": "field"
      }
    }
}

eager_global_ordinals

默认false,因为这份字典需要常驻内存,并且每次refresh以后就会重构,所以增大了内存以及cpu的消耗。推荐在低写高查、数据量不大的index中使用。

fields

为字段提供不同方式的类型方式,比如 A字段可以实现text类型,keyWord类型,不同的分词器,可用来查询,聚合等

#创建mapping
PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"keyword", 
         "fields": {
           "text":{ //fields名称
             "type":"text", //类型
             "analyzer": "standard" //设置分词 
           }
         }
       }
    }
  }
}
#添加数据
POST es_field_type/_doc
{
  "fieldName":"hello! elasticsearch"
}
#查询keyword(不能被分词)
GET es_field_type/_search
{
  "query": {
    "term": {
      "fieldName": {
        "value": "hello! elasticsearch"
      }
    }
  }
}
#查询text(被分词)
GET es_field_type/_search
{
  "query": {
    "match": {
      "fieldName.text": "hello"
    }
  }
}

ignore_above

在keyword中限制被字符索引的长度 默认256;

PUT /es_field_type?pretty=true
{
  "mappings":{
    "properties":{
       "fieldName":{  
         "type":"keyword", 
         "ignore_above": 2//设置只能索引2个字符
       }
    }
  }
}

#添加数据 e es elastic
POST es_field_type/_doc
{
  "fieldName":"elastic"
}

实际中只有 e 和es 被搜索到 因为elastic超出索引范围

index_options

作用是用于控制倒排索引记录的内容

format

  • epoch_millis||epoch_second:java时间毫秒||分钟数(毫秒/1000)

  • date_optional_time || strict_date_optional_time :通用ISO格式

  • basic_date: yyyMMdd

  • basic_date_time : yyyyMMdd’T’HHmmss.SSSZ

  • basic_date_time_no_millis: yyyyMMdd’T’HHmmssZ (没有毫秒的格式化程序)

  • basic_ordinal_date:一个用于 ordinal date 的格式化程序,使用四位数字的年份和三位数的日期,yyyyDDD。

  • basic_ordinal_date_time:一个用于完整的 ordinal 日期和时间的格式化程序,使用四位数的年份和三位数的日期: yyyyDDD’T’HHmmss.SSSZ.

  • basic_ordinal_date_time_no_millis:一个用于完整的 ordinal 日期和时间且没有毫秒的格式化程序,使用四位数的年份和三位数的日期: yyyyDDD’T’HHmmssZ.

  • basic_time:一个两位数的小时,两位数的分钟,两位数的秒,三位数的毫秒以及时间偏移量的格式化程序:HHmmss.SSSZ.

  • basic_time_no_millis:一个两位数的小时,两位数的分钟,两位数的秒以及时间偏移量的格式化程序:HHmmssZ

  • basic_t_time:一个两位数的小时,两位数的分钟,两位数的秒,三位数的毫秒以及以T为前缀的时区:'T’HHmmss.SSSZ.

  • basic_t_time_no_millis:一个两位数的小时,两位数的分钟,两位数的秒以及以T为前缀的时区:'T’HHmmssZ.

  • basic_week_date or strict_basic_week_date:一个四位数的weekyear,两位数的周数,一位数的天数:xxxx’W’wwe。

  • basic_week_date_time or strict_basic_week_date_time:一个包含基础的 weekyear 日期和时间的格式化程序,通过T分割: xxxx’W’wwe’T’HHmmss.SSSZ.

  • basic_week_date_time_no_millis or strict_basic_week_date_time_no_millis:一个包含基础的 weekyear 日期和时间且不包含毫秒的格式化程序,通过T分割 😗* xxxx’W’wwe’T’HHmmssZ**.

  • date or strict_date:一个完整日期的格式化程序,四位数的年,两位数的月,两位数的天: yyyy-MM-dd.

  • date_hour or strict_date_hour:一个包含完整日期和两位数的小时的格式化程序: yyyy-MM-dd’T’HH.

-date_hour_minute or strict_date_hour_minute:一个包含完整日期,两位数的天数,两位数的分钟的格式化程序: yyyy-MM-dd’T’HH:mm.

-date_hour_minute_second or strict_date_hour_minute_second:一个包含完整日期,两位数的天数,两位数的分钟,两位数的秒数: yyyy-MM-dd’T’HH:mm:ss.

  • date_hour_minute_second_fraction or strict_date_hour_minute_second_fraction:一个包含完整日期,两位数的小时数,两位数的分钟数,两位数的秒数,三位数的秒的分数:yyyy-MM-dd’T’HH:mm:ss.SSS.

  • date_hour_minute_second_millis or strict_date_hour_minute_second_millis:一个包含完整日期,两位数的小时,两位数的分钟,两位数的秒数,三位数的秒的分数: yyyy-MM-dd’T’HH:mm:ss.SSS.

  • date_time or strict_date_time:一个包含完整日期和时间,通过T分割的格式化程序: yyyy-MM-dd’T’HH:mm:ss.SSSZZ.

  • date_time_no_millis or strict_date_time_no_millis:一个包含完整日期和时间且没有毫秒的,通过T分割的格式化程序: yyyy-MM-dd’T’HH:mm:ssZZ.

  • hour or strict_hour:一个两位数的小时数的格式化程序: HH

  • hour_minute or strict_hour_minute:一个两位数的小时数和两位数的分钟数:HH:mm.

  • hour_minute_second or strict_hour_minute_second:一个两位数的小时数,两位数的分钟数和两位数的秒数:HH:mm:ss.

  • hour_minute_second_fraction or strict_hour_minute_second_fraction:一个两位数的小时数,两位数的分钟数,两位数的秒数,三位数的秒的分数:HH:mm:ss.SSS.

  • hour_minute_second_millis or strict_hour_minute_second_millis:一个两位数的小时数,两位数的分钟数,两位数的秒数,三位数的秒的分数: HH:mm:ss.SSS.

  • ordinal_date or strict_ordinal_date:一个完整日期的格式化程序,使用四位数的年数和三位数年的天数:yyyy-DDD.

  • ordinal_date_time or strict_ordinal_date_time:一个完整ordinal 日期和时间的格式化程序,使用四位数的年数和三位数的天数:yyyy-DDD’T’HH:mm:ss.SSSZZ.

  • ordinal_date_time_no_millis or strict_ordinal_date_time_no_millis:一个完整日期和时间没有毫秒的格式化程序,使用四位数的年份和三位数的年的天数: yyyy-DDD’T’HH:mm:ssZZ.

  • time or strict_time:一个两位数的天数,两位数的小时,两位数的秒,三位数的秒的分数,以及时间偏移量:HH:mm:ss.SSSZZ.

  • time_no_millis or strict_time_no_millis:一个两位数的小时,两位数的分钟,两位数的秒以及时间偏移量:HH:mm:ssZZ.

  • t_time or strict_t_time:一个两位数的小时,两位数的分钟,两位数的秒,三位数的秒的分数以及以T为前缀的时间偏移量: 'T’HH:mm:ss.SSSZZ.

  • t_time_no_millis or strict_t_time_no_millis:一个两位数的小时,两位数的分钟,两位数的秒以及以T为前缀的时间偏移量:'T’HH:mm:ssZZ.

  • week_date or strict_week_date:一个完整日其的格式化程序,四位数的weekyear,两位数的周数,一位数的天数: xxxx-'W’ww-e.

  • week_date_time or strict_week_date_time:一个包含完整weekyear 日期和时间的格式化程序,通过T进行分割:xxxx-'W’ww-e’T’HH:mm:ss.SSSZZ.

  • week_date_time_no_millis or strict_week_date_time_no_millis:一个包含完整 weekyear 日期和时间没有毫秒,以T分割的格式化程序: xxxx-'W’ww-e’T’HH:mm:ssZZ.

  • weekyear or strict_weekyear:一个四位数的 weekyear 的格式化程序:xxxx

  • weekyear_week or strict_weekyear_week:一个四位数的 weekyear 和两位数的周数:xxxx-'W’ww.

  • weekyear_week_day or strict_weekyear_week_day:一个四位数的weekyear 两位数的周数,一位数的天数: xxxx-'W’ww-e.

  • year or strict_year:一个四位数年份的格式化程序:yyyy.

  • year_month or strict_year_month:一个四位数年份和两位数月份的格式化程序: yyyy-MM.

  • year_month_day or strict_year_month_day:一个四位数的年份和两位数的月份,两位数的天数的格式化程序:yyyy-MM-dd.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值