zoukankan      html  css  js  c++  java
  • 05_Elasticsearch 单模式下API的增删改查操作

    05_Elasticsearch 单模式下API的增删改查操作
    
    
    安装marvel 插件:
    zjtest7-redis:/usr/local/elasticsearch-2.3.4# bin/plugin install license
    -> Installing license...
    Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.3.4/license-2.3.4.zip ...
    Downloading .......DONE
    Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/license/2.3.4/license-2.3.4.zip checksums if available ...
    Downloading .DONE
    Installed license into /usr/local/elasticsearch-2.3.4/plugins/license
    
    
    zjtest7-redis:/usr/local/elasticsearch-2.3.4# bin/plugin install marvel-agent
    -> Installing marvel-agent...
    Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/marvel-agent/2.3.4/marvel-agent-2.3.4.zip ...
    Downloading ..........DONE
    Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/marvel-agent/2.3.4/marvel-agent-2.3.4.zip checksums if available ...
    Downloading .DONE
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @     WARNING: plugin requires additional permissions     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    * java.lang.RuntimePermission setFactory
    * javax.net.ssl.SSLPermission setHostnameVerifier
    See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
    for descriptions of what these permissions allow and the associated risks.
    
    Continue with installation? [y/N]y
    Installed marvel-agent into /usr/local/elasticsearch-2.3.4/plugins/marvel-agent
    zjtest7-redis:/usr/local/elasticsearch-2.3.4# 
    
    ./elasticsearch/bin/plugin install marvel-agent 
    ./kiabana/bin/kibana plugin --install elasticsearch/marvel/latest 
    
    5.1  索引初始化操作;
    
    创建索引之前可以对索引做初始化操作,
    
    比如指定shards数量以及replicas的数量
    
    
    
    http://192.168.32.81:9200/library/
                             PUT
    {"settings":{"number_of_shards":3,"number_of_replicas":0}}
    
    
    
    GET  方法:
    http://192.168.32.81:9200/library/
                              GET
    查询
    
    
    {
    
        "library": {
            "aliases": { },
            "mappings": { },
            "settings": {
                "index": {
                    "creation_date": "1473139251510",
                    "number_of_shards": "3",
                    "number_of_replicas": "0",
                    "uuid": "EWWTPObRSpKyQW8pVgWYGQ",
                    "version": {
                        "created": "2030499"
                    }
                }
            },
            "warmers": { }
        }
    
    }
    
    
    获取内容;
    http://192.168.32.81:9200/library/_settings/
                                        GET
    
    {
    
        "library": {
            "settings": {
                "index": {
                    "creation_date": "1473139251510",
                    "number_of_shards": "3",
                    "number_of_replicas": "0",
                    "uuid": "EWWTPObRSpKyQW8pVgWYGQ",
                    "version": {
                        "created": "2030499"
                    }
                }
            }
        }
    
    }
    
    
    5.2 通过API创建,删除索引
    
            索引名称
            |
            |     |Type名称
            |     |
    PUT /library/books/1 --文档ID
    
    
    http://192.168.32.81:9200/library/books/1/
                                  PUT
    {
     "title":"Elasticsearch:The scan",
       "name" : {
               "first":"aaa",
                "last" :"bbb"
           },
           "publish_date":"2016-09-06",
            "price":"49"
    }
    
    
    通过_source获取指定字段名称:
    
    http://192.168.32.81:9200/
    library/books/1/?_source=price  GET
    
    返回:
    {
    
        "_index": "library",
        "_type": "books",
        "_id": "1",
        "_version": 10,
        "found": true,
        "_source": {
            "price": "49"
        }
    
    }
    
    
    更新:
    http://192.168.32.81:9200/
    library/books/1/_update                    POST
    
    
    {
       "doc":{
        "price":10.001
    }
    }
    

  • 相关阅读:
    【More Effective C++ 条款4】非必要不提供default constructor
    【More Effective C++ 条款3】最好不要以多态方式处理数组
    【C++】Debug模式和Release模式的区别
    【More Effective C++ 条款2】最好使用C++转型操作符
    【More Effective C++ 条款1】仔细区别pointers和references
    程序崩溃时的堆栈捕捉
    快速排序--来自维基百科
    十六进制转为字符串
    linux那些事
    svnsync备份
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199246.html
Copyright © 2011-2022 走看看