zoukankan      html  css  js  c++  java
  • Elasticsearch (二) 索引

    Elasticsearch 官方使用手册>>

    模拟需求:

    • 一个新闻
    • 可以进行新闻检索

    数据库设计

    Tab:news_info

    | id | news_type | title | content | author | create_time | read_number |

    新建索引

    //格式
    [GET] http://host:port/索引名称
    //例如
    [GET] http://host:port/news
    //返回
    {
        "acknowledged": true, 
        "shards_acknowledged": true,
        "index": "news_box"
    }

    查看索引

    //格式
    [GET] http://host:port/索引名称/_settings
    //例如
    [GET] http://host:port/news/_settings
    //返回
    {
        "news": {
            "settings": {
                "index": {
                    "creation_date": "1578991439484",
                    "number_of_shards": "5",
                    "number_of_replicas": "1",
                    "uuid": "bGscXThhSuSTJhG6t4KfGg",
                    "version": {
                        "created": "6080699"
                    },
                    "provided_name": "news"
                }
            }
        }
    }

    查看多个索引

    //格式
    [GET] http://host:port/索引名称1,索引名称1/_settings #查看多个索引
    [GET] http://host:port/_all/_settings #查看所有索引 //例如 [GET] http://host:port/news,news2/_settings //返回 { "news2": { "settings": { "index": { "creation_date": "1578991693537", "number_of_shards": "5", "number_of_replicas": "1", "uuid": "axD970x6TrOL-LATe5Vhdg", "version": { "created": "6080699" }, "provided_name": "news2" } } }, "news": { "settings": { "index": { "creation_date": "1578991439484", "number_of_shards": "5", "number_of_replicas": "1", "uuid": "bGscXThhSuSTJhG6t4KfGg", "version": { "created": "6080699" }, "provided_name": "news" } } } }

    删除索引

    //格式
    [DELETE] http://host:port/索引名称
    //例如
    [DELETE] http://host:port/news
    //返回
    {
        "acknowledged": true
    }

    关闭索引

    //格式
    [POST] http://host:port/索引名称/_close
    //例如
    [POST] http://host:port/news/_close
    //返回
    {
        "acknowledged": true
    }

    打开索引

    //格式
    [POST] http://host:port/索引名称/_open
    //例如
    [POST] http://host:port/news/_open
    //返回
    {
        "acknowledged": true,
        "shards_acknowledged": true
    }
  • 相关阅读:
    2019总结及2020计划
    蓝牙BLE连接与操作
    Android蓝牙操作
    Cannot use JSX unless the '--jsx' flag is provided.
    PyQt打包可执行文件
    Springboot项目报错【java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader】
    typescript枚举字符串型不能使用函数问题
    beautifulsoap常用取节点方法
    numpy常用矩阵操作
    MYSQL 碎片查询
  • 原文地址:https://www.cnblogs.com/devan/p/12193016.html
Copyright © 2011-2022 走看看