Elasticsearch increase, delete, change, check operation in-depth explanation

Source: Internet
Author: User
Tags mysql delete mysql insert mysql update kibana

Introduction:

For children who have just come into contact with ES, they often do not understand the meaning of the various ES concepts. In particular, the word "index" is more confused with the relational database. In this paper, through the comparison of relational database, the common es in the increment, delete, change, check the operation of graphics and text rendering. Can deepen your understanding of ES. At the same time, it also lists the graphical display under the Kibana.

ES Restful API GET, POST, PUT, DELETE, head meaning:
1) Get: Gets the current state of the requested object.
2) POST: Changes the current state of the object.
3) PUT: Create an object.
4) DELETE: Destroys the object.
5) HEAD: request the base information for the object.

MySQL and Elasticsearch core concept comparison

The above table is based on,
The new document in ES (under Index/type) is equivalent to inserting a row of data under MySQL (a table in a database).

1. New document (like MySQL insert insert operation)
http://localhost:9200/blog/ariticle/1 put{"title":"New version of Elasticsearch released!","content":"Version 1.0 released today!","tags":["announce","elasticsearch","release"]}

The creation succeeds as shown below:

{-"  _index": "blog",-"  _type": "Ariticle",-"  _id": "1-d",- "_version": 1,- "_shards": {- "Total": 2,- "Successful": 1,- "Failed": 0 - },- "created": true }

2. Retrieving documents (similar to MySQL search select* operation)

http://localhost:9200/blog/ariticle/1/GET

The results of the search are as follows:

{-"  _index": "blog",-"  _type": "Ariticle",-"  _id": "1",- "_version": 1,- "found": true,- "_source": {-"  title": "New version of Elasticsearch released!",- "Content": "Version 1.0 released today!",- "tags": [- "announce" - ,- "Elasticsearch" - ,- "Release" - ]- }}

If you do not find the prompt:

{- "_index": "blog",- "_type": "ariticle",- "_id": "11",- "found": false}

Query all documents as follows:

A specific detail of the content of the search,
Query Example 1: Query the cotent column contains the information for version 1.0.
http://localhost:9200/blog/
_search?pretty&q=content:1.0

{- "took": 2,- "Timed_out": false,- "_shards": {- "Total": 5,- "Successful": 5,- "Failed": 0 - },- "hits": {- "Total": 1,- "Max_score": 0. 8784157,- "hits": [- {-"  _index": "blog",-"  _type": "Ariticle",-"  _id": "6",- "_score": 0. 8784157,- "_source": {-"  title": "Deep elasticsearch!",- "Content": "Version 1.0!",- "tags": [- "Deep" - ,- "Elasticsearch" - ]- }- }- ]- }}

Query Example 2: Query the title title contains data information for the "Enhance" field:
[Email protected] ~]# curl-xget 10.200.1.121:9200/blog/ariticle/_search?pretty-d '

> {"Query": {>"term":> {"title":"Enhance"}>}>} ' {"took":189,"Timed_out":false,"_shards": {"Total":5,"Successful":5,"Failed":0},"hits": {"Total":2,"Max_score":0.8784157,"hits": [ {"_index":"Blog","_type":"Ariticle","_id":"4","_score":0.8784157,"_source": {"title":"Enhance elasticsearch!","Content":"Version 4.0!","tags": ["Enhance","Elasticsearch"]  }  }, {"_index":"Blog","_type":"Ariticle","_id":"5","_score":0.15342641,"_source": {"title":"Enhance Elasticsearch for university!","Content":"Version 5.0!","tags": ["Enhance","Elasticsearch"]  }  } ]  }}

Query Example 3: query for data information with ID value 3,5,7:
[Email protected] ~]# curl-xget 10.200.1.121:9200/blog/ariticle/_search?pretty-d '

{"Query": {"Terms":{"_id":[ "3", "5", "7" ]}}}' {'Took": 5,"Timed_out": false,"_shards" : {  "Total": 5,"Successful": 5,"Failed": 0},"Hits" : {  "Total": 3,"Max_score": 0.19245009,"Hits" : [ {  "_index" : "Blog",  "_type" : "Ariticle",  "_id" : "5",  "_score": 0.19245009,"_source" : {  "Title" : "Enhance Elasticsearch foruniversity!",  "Content" : "Version5.0!",  "Tags" : [ "Enhance", "Elasticsearch" ]  }  }, {  "_index" : "Blog",  "_type" : "Ariticle",  "_id" : "7",  "_score": 0.19245009,"_source" : {  "Title" : "Deep Elasticsearch foruniversity!",  "Content" : "Version2.0!",  "Tags" : [ "Deep", "Elasticsearch", "University" ]  }  }, {  "_index" : "Blog",  "_type" : "Ariticle",  "_id" : "3",  "_score": 0.19245009,"_source" : {  "Title" : "Init Elasticsearch foruniversity!",  "Content" : "Version3.0!",  "Tags" : [ "Initialize", "Elasticsearch" ]  }  } ]  }}
3, update the document (similar to MySQL update operation)

Http://localhost:9200/blog/ariticle/1/_update/POST
{"Script": "ctx._source.content = \" New version 2.0 20160714\ ""}

After the update, the results show:
{

    • "_index": "Blog",
    • "_type": "Ariticle",
    • "_id": "1",
    • "_version": 2,
    • "_shards": {
      • "Total": 2,
      • "Successful": 1,
      • "Failed": 0
    • }

}

Query & Verify updated results: (compared to the version number has been updated)
http://localhost:9200/blog/ariticle/1/

{-"  _index": "blog",-"  _type": "Ariticle",-"  _id": "1",- "_version": 2,- "found": true,- "_source": {-"  title": "New version of Elasticsearch released!",-"  Content": "new version 2.0 20160714",- "tags": [- "announce" - ,- "Elasticsearch" - ,- "Release" - ]- }}`! [Write a description of the picture here] (http://img.blog.csdn.net/20160717132407353) "Note that updating the document requires the following additions under Elasticsearch_win\config\elasticsearch.yml:

Script.groovy.sandbox.enabled:true
Script.engine.groovy.inline.search:on
Script.engine.groovy.inline.update:on
Script.inline:on
Script.indexed:on
Script.engine.groovy.inline.aggs:on
Index.mapper.dynamic:true

4. Delete document (like MySQL delete operation)

http://localhost:9200/blog/ariticle/8/return Results

{- "found": true,-"  _index": "blog",-"  _type": "Ariticle",-"  _id": "8",- "_version": 2,- "_shards": {- "Total": 2,- "Successful": 1,- "Failed": 0 - }}

5, Kibana Visual Analysis 5.1, on the Index blog query contains the "University" field information.

5.2. Kibana Multi-Dimension analysis

July 17, 2016 13:31 think at home in front of the bed

Ming Yi World
Reprint please indicate source, original address: http://blog.csdn.net/laoyang360/article/details/51931981
If you feel this article is helpful, please click on the ' top ' support, your support is I insist on writing the most power, thank you!

Elasticsearch increase, delete, change, check operation in-depth explanation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.