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)