zoukankan      html  css  js  c++  java
  • mapping 详解4(mapping setting)

    mapping type

    映射设置一般发生在:

    1. 增加新的 index 的时候,添加 mapping type,对 fields 的映射进行设置

    PUT twitter 
    {
      "mappings": {
        "tweet": {
          "properties": {
            "message": {
              "type": "string"
            }
          }
        }
      }
    }

    2. 为 index 增加新的 mapping type,对 fields 的映射进行设置

    PUT twitter/_mapping/user 
    {
      "properties": {
        "name": {
          "type": "string"
        }
      }
    }

    3. 为已有 mapping type 增加新的 fields 映射设置

    PUT twitter/_mapping/tweet 
    {
      "properties": {
        "user_name": {
          "type": "string"
        }
      }
    }

    设置方式

    1. 在 PUT 请求体中给出完整的 mapping 设置

    PUT twitter 
    {
      "mappings": {                         //mappings 对象,说明进行 mapping 设置
        "tweet": {                          //指定 mapping type
          "properties": {                   //指定 mapping type 的 properties 设置
            "message": {                    //对字段 message 的映射进行设置
              "type": "string"              //mapping 参数配置
            }
          }
        }
      }
    }

    增加 index 的时候,除了可以设置 mapping type,还可以对 index 进行设置,比如配置自定义 analyzer、索引分片个数设置等

    PUT /my_index
    {
      "settings": {
        "analysis": {
          "analyzer": {
            "autocomplete": { 
              "type": "custom",
              "tokenizer": "standard",
              "filter": [
                "lowercase",
                "autocomplete_filter"
              ]
            }
          }
        }
      },
      "mappings": {
        "my_type": {
          "properties": {
            "text": {
              "type": "string",
              "analyzer": "autocomplete"
            }
          }
        }
      }
    }

    2. 在 PUT 请求 URI 中指定 type,并在请求体中给出 type 的各项设置

    PUT twitter/_mapping/user 
    {
      "properties": {                   //指定 mapping type 的 properties 设置
        "name": {                       //对字段 message 的映射进行设置
          "type": "string"              //mapping 参数配置
        }
      }
    }

    3. 一个完整的 mapping type 设置包括:Meta-fields 和 Fields 或者 properties 设置

    PUT my_index
    {
      "mappings": {
        "type_1": { 
          "properties": {...}           //properties 设置
        },
        "type_2": { 
          "_all": {                     //meta-fields 设置
            "enabled": false
          },
          "properties": {...}
        }
      }
    }
  • 相关阅读:
    django 我的博客 (慕课网视频)笔记
    读 django 中文文档投票例子笔记
    django的安装和初步使用
    Debug模式自定义NSlog
    重写NSString的setter方法
    iOS 常用代码之 UICollectionView
    生成100个 "20180520" 这样的时间字符串 写入txt文件
    WRNavigationBar 使用记录
    关于iphone设置显示模式为标准模式和放大模式时的区别
    CGContextRef 使用小记
  • 原文地址:https://www.cnblogs.com/licongyu/p/5495477.html
Copyright © 2011-2022 走看看