• 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
    }
  • 相关阅读:
    被下属骂,记一次矛盾升级——有心无心,蝴蝶效应?
    技术管理进阶——团队合并、解散怎么办?
    “技术转产品”比产品更恶心的几个点
    javaScript系列 [43]TS、Class and ES5
    javaScript系列 [42]node中 require函数的加载过程
    javaScript系列 [52]模板引擎的实现逻辑
    Base64简单介绍
    异或运算(XOR)
    javaScript系列 [51]Rollup 打包器
    javaScript系列 [49] ast && render
  • 原文地址:https://www.cnblogs.com/devan/p/12193016.html
Copyright © 2020-2023  润新知