elasticsearch 2.1.0 curl 관련 조작 명령(1)

이것 은 제 가 es 를 공부 하고 사용 하 는 과정 에서 기록 한 curl 관련 명령 입 니 다.여기 서 기록 을 해서 후속 검색 을 준비 합 니 다.
(1)     http://10.4.30.81:9200/_plugin/head/
http://10.4.30.151:9200/_plugin/head/

(2)        
curl 'http://10.4.30.81:9200/?pretty'
curl 'http://10.4.30.151:9200/?pretty'

java   api  
https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.0/node-client.html
https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.1/transport-client.html

(3-1)      (          )
curl -XPUT 'http://10.4.30.151:9200/megacorp/employee/11' -d '{
    "first_name" : "John4",
    "last_name" :  "Smith4",
    "age" :        35,
    "about" :      "I love to go rock climbing3",
    "interests": [ "sports4" ],
	"yujie_name":"wangyujie"
}'
  Elasticsearch             。           (    ), _version      


(3-2)   post       id
curl -XPOST 'http://10.4.30.151:9200/megacorp/employee?pretty' -H 'Content-Type: application/json' -d'{
    "first_name" : "John7",
    "last_name" :  "Smith7",
    "age" :        37,
    "about" :      "I love to go rock climbing7",
    "interests": [ "sports7" ]
}'

    :
{
  "_index" : "megacorp",
  "_type" : "employee",
  "_id" : "AWBNtXOoxFnukAxvHpYx",
  "_version" : 1,
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "created" : true
}

(3-3)           ;          
curl -XPUT 'http://10.4.30.151:9200/megacorp/employee/1?op_type=create' -d '{
    "first_name" : "John4",
    "last_name" :  "Smith4",
    "age" :        35,
    "about" :      "I love to go rock climbing3",
    "interests": [ "sports4" ]
}'
  
curl -XPUT 'http://10.4.30.151:9200/megacorp/employee/1/_create' -d '{
    "first_name" : "John4",
    "last_name" :  "Smith4",
    "age" :        35,
    "about" :      "I love to go rock climbing3",
    "interests": [ "sports4" ]
}'


      ID   URL-safe、    Base64       20     GUID    。
    GUID          FlakeID     ,                 ID ,              
 
(4-1)        id       
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/1'
  :
{"_index":"megacorp","_type":"employee","_id":"1","_version":1,"found":true,"_source":
{
    "first_name" : "John",
    "last_name" :  "Smith",
    "age" :        25,
    "about" :      "I love to go rock climbing",
    "interests": [ "sports", "music" ]
}}

(4-2)        id           _source  
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/1/_source?pretty'
    :
{
    "first_name" : "John",
    "last_name" :  "Smith",
    "age" :        25,
    "about" :      "I love to go rock climbing",
    "interests": [ "sports", "music" ]
}

(4-3)             HEAD
curl -i -XHEAD 'http://10.4.30.151:9200/megacorp/employee/1'
      , Elasticsearch       200 ok     ,     404


(4-4)       
curl -XDELETE 'http://10.4.30.151:9200/megacorp/employee/1?pretty'


(4-5)es                         
curl -XPUT 'http://10.4.30.151:9200/megacorp/employee/1?version=1&pretty' -H 'Content-Type: application/json' -d'{
  "title": "My first blog entry",
  "text":  "Starting to get the hang of this..."
}'
    es      version=2,         409 Conflict HTTP    。
         es   ,          ,    1           。

(4-6)    
curl -XPOST 'http://10.4.30.151:9200/megacorp/employee/4/_update?pretty' -H 'Content-Type: application/json' -d'{
   "doc" : {
      "tags" : [ "testing" ],
      "views": 0
   }
}'
             ,       

(4-7)      
curl -XGET 'http://10.4.30.151:9200/_mget?pretty' -H 'Content-Type: application/json' -d'
{
   "docs" : [
      {
         "_index" : "megacorp",
         "_type" :  "employee",
         "_id" :    2
      },
      {
         "_index" : "website",
         "_type" :  "pageviews",
         "_id" :    1,
         "_source": "views"
      }
   ]
}'

            ,        ids  
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_mget?pretty' -H 'Content-Type: application/json' -d'{
	"ids" : [ "1", "2" ,"3","4","5"]
}'

(5-1)             10   
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_search'

(5-2)              10   
curl -XGET 'http://10.4.30.151:9200/_search?pretty'
curl -XGET 'http://10.4.30.151:9200/_search?pretty' -H 'Content-Type: application/json' -d'{
    "query": {
        "match_all": {}
    }
}'


(5-3)     size:       ,from:            
curl -XGET 'http://10.4.30.151:9200/_search?size=5&pretty'
curl -XGET 'http://10.4.30.151:9200/_search?size=5&from=5&pretty'
curl -XGET 'http://10.4.30.151:9200/_search?size=5&from=10&pretty'

curl -XGET 'http://10.4.30.151:9200/_search?pretty' -H 'Content-Type: application/json' -d'{
  "from": 5,
  "size": 4}'



(6)(    )   megacorp     employee   last_name Smith   
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_search?q=last_name:wang6&pretty'
curl -XGET 'http://10.4.30.151:9200/_search?pretty' -H 'Content-Type: application/json' -d '{
    "query": {
        "match": {
            "last_name": "wang6"
        }
    }
}'


(7)DSL(      )          (6)    
    
curl -XGET 'http://10.4.30.151:9200/_search?pretty' -H 'Content-Type: application/json' -d '{
    "query": {
        "match": {
            "last_name": "wang6"
        }
    }
}'

filter         
curl -XGET 'http://10.4.30.151:9200/_search?pretty' -H 'Content-Type: application/json' -d '{
       "query" : {
        "bool" : {
            "filter" : {
                "term" : {
                    "last_name": "wang6"
                }
            }
        }
    }
}'


(8)     
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_search' -d '{
 "query" : {
        "bool": {
            "must": {
                "match" : {
                    "last_name" : "smith" 
                }
            },
            "filter": {
                "range" : {
                    "age" : { "gt" : 30 } //    30  grant than
                }
            }
        }
    }
}'

(9)    
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_search' -d '{
    "query" : {
        "match" : {
            "about" : "rock climbing"
        }
    }
}'

(10)      
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_search' -d '{
    "query" : {
        "match_phrase" : {
            "about" : "rock climbing"
        }
    }
}'

(11)    
curl -XGET 'http://10.4.30.151:9200/megacorp/employee/_search' -d '{

    "query" : {
        "match_phrase" : {
            "about" : "rock climbing"
        }
    },
    "highlight": {
        "fields" : {
            "about" : {}
        }
    }
}'

(12)         
curl -XGET 'http://10.4.30.151:9200/_cluster/health?pretty'

(13)    
curl -XPUT 'http://10.4.30.151:9200/blogs' -d '{
 "settings" : {
      "number_of_shards" : 3,
      "number_of_replicas" : 1
   }
}'
   ,        ,        ,      
_type            ,              ,       ,        256   
           _id  ,    index API     。

(14)                 
curl -XPUT 'http://10.4.30.151:9200/blogs/_settings' -d '{
	"number_of_replicas" : 2
}'

  ,                               ,
                  。                   

좋은 웹페이지 즐겨찾기