zoukankan      html  css  js  c++  java
  • Elasticsearch7.9:一、索引基础

    1、索引命名规范

      索引命名有如下限制:

    •  仅限小写字母
    •  不能包含 /*?"<>|、# 以及 空格符等 特殊符号
    •  从 7.0 版本开始不再包含 冒号
    •  不能以  -_ + 开头
    •  不能超过 255 个字节(注意它是字节,因此多字节字符将计入255个限制)

    2、新建索引

    (1)索引名小写

      

     (2)索引名不能包含大些字母

      PUT Blog

    {
      "error": {
        "root_cause": [
          {
            "type": "invalid_index_name_exception",
            "reason": "Invalid index name [Blog], must be lowercase",
            "index_uuid": "_na_",
            "index": "Blog"
          }
        ],
        "type": "invalid_index_name_exception",
        "reason": "Invalid index name [Blog], must be lowercase",
        "index_uuid": "_na_",
        "index": "Blog"
      },
      "status": 400
    }

    3、索引配置

      创建索引时,可以制定相关设置,比如设置索引的分片数 number_of_shards 和 副本数 number_of_replicas

    PUT blog
    {
        "settings" : {
            "index" : {
                "number_of_shards" : 2,
                "number_of_replicas" : 2
            }
        }
    }

      也可以简化为:

    PUT blog
    {
        "settings" : {
            "number_of_shards" : 2,
            "number_of_replicas" : 2
        }
    }

      也就是说,不必在settings部分中明确指定索引部分。

    4、查看索引及配置信息

    (1)查看制定索引

    GET blog

    (2)查看索引列表

    GET /_cat/indices?v

    (3)判定索引是否存在

    HEAD blog

    5、索引别名

    (1)添加别名

    POST _aliases
    {
      "actions": [
        {
          "add": {
            "indices": ["index2","test"],
            "alias": "alias1"
          }
        }
      ]
    }

    (2)移除别名

    POST _aliases
    {
      "actions": [
        {
          "remove": {
            "index": "test",
            "alias": "alias1"
          }
        }
      ]
    }

    (3)查看别名

    GET alias1
  • 相关阅读:
    关于存储过程
    关于TSql
    SQL问题+知识点总结总
    基于IEC61499标准的组件
    使用Irony开发译码器
    C#早期绑定&后期绑定
    .NET组件 vs. COM组件
    C#委托和事件
    广度优先搜索(BreadthFirstSearch)& 迪克斯特拉算法 (Dijkstra's algorithm)
    选择排序法&快速排序法
  • 原文地址:https://www.cnblogs.com/liang1101/p/13629844.html
Copyright © 2011-2022 走看看