Large data Elasticsearch basic operation of Elasticsearch


1. The basic operation of the index

1.1 New Index

PUT request can be issued directly to the Elastic Server
Index to create a new named the weather

$ curl -X PUT 'localhost:9200/weather'

The server returns a JSON object, which is acknowledged field indicates a successful operation.
{ "Acknowledged": true, " shards_acknowledged": true}

1.2 Delete Index

DELETE to send a request to delete

$ curl -X DELETE 'localhost:9200/weather'

1.3 New Record

PUT request specifies a new record id, id to a string.

$ curl -X PUT 'localhost:9200/accounts/1' -d ' { "user": "张三", "title": "工程师", "desc": "数据库管理" }'

POST request is automatically generated random string id

1.4 View Record

To / Index / Type / Id issue a GET request, returns the parameter represented in pretty = true readable format

$ curl 'localhost:9200/accounts/1?pretty=true'

1.5 Delete Record

Issue DELETE requests

$ curl -X DELETE 'localhost:9200/accounts/1'

1.6 update records

A PUT request, retransmits the data, the data returned JSON vary accordingly: Id has not changed, the version (Version) from 2 becomes 1, the type of operation (result) from the created becomes Updated, created field becomes false


2. Data Query

2.1 returns all records

GET request / Index / Type / _search
return the default data sorted by relevancy _score

2.2 full-text search

Unique query syntax, data volume with claim GET request, returns default data 10, by changing the size field, in fact, specified by the field from the position

$ curl 'localhost:9200/accounts/person/_search' -d ' { "query" : { "match" : { "desc" : "软件" }}, "from": 1, "size": 20 }'
Published 204 original articles · won praise 59 · Views 140,000 +

Guess you like

Origin blog.csdn.net/baidu_34122324/article/details/102525703