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
    }
    }
    

  • 相关阅读:
    R绘图学习笔记
    SVM与LR的比较
    精简android4.2
    vbox下android分辨率设置
    centos7命令
    mysql设置编码
    virutalbox虚拟机硬盘扩容
    spring boot学习
    SQL Server 2012清除连接过的服务器名称历史
    android AutoCompleteTextView和Spinner选中项加亮
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350301.html
Copyright © 2011-2022 走看看