Elasticsearch Mapping之字段类型(field datatypes)


基本类型

String(字符串类型)

  • text
    文本类型,在索引文件中,存储的不是原字符串,而是使用分词器对内容进行分词处理后得到一系列的词根,然后一一存储在index的倒排索引中。
    text类型支持如下映射参数:
    analy-zer、boost、eager_global_ordina-ls、fielddata、fielddata_frequency-filt-er、fields、index、index_optio-ns、index_prefixes、index_phras-es、norms、position_increment_g-ap、store、search_analyzer、sea-rch_quote_analyzer、similarity、t-erm_vector。

  • keyword
    关键字类型,将原始输入内容当成一个词根存储在倒排索引中,与text字段的区别是该字段不会使用分词器进行分词。
    keyword类型支持如下映射参数:
    d-oc_values、boost、eager_global_-ordinals、fields、ignore_above、i-ndex、index_options、norms、nu-ll_value、store、similarity、norma-lizer、split_queries_on_whitespac-e。

numeric datatypes(数字类型)

long、integer、short、byte、double、float、half_float、scaled_float。

  • long
    取值范围: -2^63~2^63-1(与java取值范围一致)
  • integer
    取值范围:-2^31~2^31-1.(与java取值范围一致)
  • short
    取值范围:-32,768~32,767(与java取值范围一致)
  • byte
    取值范围:-128~127(与java取值范围一致)
  • double
    与java取值范围一致
  • float
    与java取值范围一致
  • half_float
    浮点数,但只是用16位
  • scaled_float
    底层基于long存储,支持一个固定的精度因子,什么意思呢?如果存储浮点数0.15,如果设置scaling_fac-tor=100,则该类型会以一个整数15进行存储,有效提高其存储性能。

数值型数据类型,支持如下映射类型:boost、doc_values、format、locale、ignore_malformed、inde-x、null_value、store。


复合类型


特定类型