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
    }
  • 相关阅读:
    作业
    函数
    集合及特殊集合
    VS2010中安装AjaxControlToolkit
    连接SQLServer OLEDB数据库(ACCESS) ODBC Oracle
    设置热键 默认焦距 提交时弹出确认信息
    显示长日期格式时间
    FileUpLoad控件
    按钮类型控件 选择类型控件
    Textbox服务器控件
  • 原文地址:https://www.cnblogs.com/devan/p/12193016.html
Copyright © 2011-2022 走看看