zoukankan      html  css  js  c++  java
  • ElasticSearch映射

    ES有个强大的功能,在索引的同时自动完成索引、类型、映射的创建。

    什么是映射呢?映射就是描述字段的类型、如何进行分析、如何进行索引等内容。

    字段自动检测

    字段如果在定义是没有映射,ES会自动检测他可能对应的字段类型,创建相应的映射。
    JSON数据 ES中数据类型
    null null
    true、false boolean
    浮点数 double
    整数 long
    object object
    数组 取决于第一个非空的值
    字符串 如果可以转换为date,则为date
    可以转化为数字,则为number

    以上是自动检测的基本结果,其他高级的类型如ip、geo手动指定。

    日期自动检测

    日期自动检测,即date_detection是默认开启的,因此只要符合默认的日期格式,就可以自动创建成date类型

    日期的格式为:

    [ "strict_date_optional_time","yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"]

    如:

    原始数据格式为:

    _index
    _type
    _id
    _score
    title
    text
    date
    website blog 123 1 My first blog entry Just trying this out... 2014/01/01

    通过 http://localhost:9200/website/_mapping?pretty/  查看:

    {

    • "website": {
      • "mappings": {
        • "blog": {
          • "properties": {
            • "date": {
              • "type""date",
              • "format""yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis"
              },
            • "text": {
              • "type""string"
              },
            • "title": {
              • "type""string"
              }
            }
          }
        }
      }
    }

    数字自动检测

    数字自动检测,即numeric_detection默认是关闭的。因此需要手动打开:

    PUT my_index
    {"mappings":{"my_type":{"numeric_detection":true}}}

  • 相关阅读:
    webpack4系列之 【2. 踩坑--webpack 2.x升级至4.x】
    计算月份差方法封装
    局域网内访问另一台电脑上运行的代码
    npm遇到的问题--npm install 执行报错 /bin/git submodule update -q --init --recursive
    功能说明书
    第一次结对作业
    MathExam
    第一次作业
    2017《Java预备作业》02 计科1501 李晓燕
    2017《Java技术》预备作业 计科1501 李晓燕
  • 原文地址:https://www.cnblogs.com/pilihaotian/p/8823178.html
Copyright © 2011-2022 走看看