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
    }
  • 相关阅读:
    asp.net mvc controller调用js
    无刷新文件上传 利用iframe实现
    Git使用
    easyui扩展
    Highcharts 多个Y轴动态刷新数据
    Android之Handler
    asp.net mvc之TempData、ViewData、ViewBag
    android之滑屏的实现
    java多线程系类:JUC线程池:05之线程池原理(四)(转)
    java多线程系类:JUC线程池:04之线程池原理(三)(转)
  • 原文地址:https://www.cnblogs.com/devan/p/12193016.html
Copyright © 2011-2022 走看看