REST API (CREATE INDEX, retrieve document)

Source: Internet
Author: User

The following is a brief introduction to the usage of the set of APIs provided by Elasticsearch:,

1. Create an index PUT

The following creates an index JIU3, which overrides the configuration information, otherwise the default of 5 shards and a copy, the mapping is written in a TYPE:LVH, and two fields. Of course, these are not necessary in curly braces.

1Curl-xput http://192.168.100.15:9200/jiu3/-d ' {2     "Settings":{3         "Index":{4             "Number_of_shards":1,5             "Number_of_replicas":06         }7     },8     "Mappings":{9         "LVH":{Ten             "Properties":{ One                 "name":{ A                     "type":"string"}, -                 " Age":{ -                     "type":"Long"} the             } -         } -     } -}'

2. Add a document POST

When you add a document, you can add it in the existing type, or you can create a new type to add the document. The unique identifier (_ID) can be written without writing.

1 curl-xpost http://192.168.100.15:9200/JIU3/LIH/1-d ' {2     '  Name":"Huan"}'

3. Get the document get

Pretty is displayed in JSON format

1 curl-xget http://192.168.100.15:9200/jiu3/lih/1?pretty

4. Retrieving a document GET

There are a variety of ways to search, simply cite a few examples:

1 curl-xget http://192.168.100.15:9200/jiu3/lih/_search?pretty
1 curl-xget http://192.168.100.15:9200/jiu3/_search?pretty&q=name:huan

REST API (CREATE INDEX, retrieve document)

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.