Elasticsearch Study Notes # 2 new entry / query / delete index / index lists all

Preparation: Start es, start kibana, use kibana of dev tools

1. Create an index called the customer

PUT /customer?pretty

result

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "customer"
}

*We simply append pretty to the end of the call to tell it to pretty-print the JSON response (if any).

2. List all the current index

GET /_cat/indices?v

result

health status index                        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   customer                     ldPujOmVRYCIUanl-SDcaQ   1   1          0            0       230b           230b

* Because the default replicas has not yet been assigned, the status is yellow, when another node joins, replicas are allocated, the state will turn green

 3. an interpolation data to costomer

PUT /customer/_doc/1?pretty
{
  "name": "John Doe"
}

 result

{
  "_index" : "customer",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

4. Just insert the query data

GET /customer/_doc/1?pretty

 result

{
  "_index" : "customer",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 25,
  "_primary_term" : 1,
  "found" : true,
  "_source" : { "name": "John Doe" }
}

5. Delete index

DELETE /customer?pretty

 result

{
  "acknowledged" : true
}

 Delete and then perform a second example of the statement to query all index, can be found at this time customer has been successfully deleted.

  

to sum up:

Es can be found in the command syntax is as follows:

<HTTP Verb> /<Index>/<Endpoint>/<ID>

  

 

Guess you like

Origin www.cnblogs.com/sunang/p/11261113.html