restful interface method
RESTful interface URL format:
Where the index, type must be provided.
id is optional and does not provide es will be automatically generated.
index, type the hierarchical information, which will help management.
It is understood that the database index; type is understood as the data table; key ID corresponding to the main database records in the table, is the only
The establishment of the second document indexing
Data will be presented as a song information to create an index es:
url : http://localhost:9200/singindex/music/1/
the Data: { "Number The": 32768, "Singer,": "Fish Leong", "size": "777", "Song": "Exhale", "Tag": "The Voice of China", "timelen": 319 };
This singindex Index beginning and not the type of music does not add a record at the same time created this index
Index name: singindex;
type index are: Music;
the above mentioned id This record is: 1
information returns can be seen to create a success, and the version number is 1; ES will record modifications made version tracking, first created 1 record, the same record every time you modify an additional 1.
The method so far submitted to a record established in the ES index, note that HTTP PUT, do not choose the wrong
Queries three index of documents
According to the document ID RESTful query when the index of the interface as follows
url: http://localhost:9200/singindex/music/1/
http get method takes the form of
Updates four index of documents
According to the updated document content ID when the index following its RESTful interface
url :
The method takes the form of HTTP PUT.
The singer by the name "Yang Kun" to "Yang Kun solo";
the result has become a field of version 2, it is because we are modified versions of the index is incremented; created field is false, indicating that this is not new but updated .
Update interface and the interface to create exactly the same, ES queries the record exists, if there is to create, update presence is operating.
The original data record
If the update statement is url: "http: // localhost: 9200 / singindex / music / 1 /" { "singer": "Fish Leong Edit"}
version 2 has become a field of representation has been updated for the record id 1 last modified
Id becomes the other data records of all lost 1 therefore update the time to update and add the same to all fields
Therefore, the statement should be updated
第三次更改此记录 此时es中的数据为(这样才是完整数据)
五 索引文档的删除
根据索引时的ID删除文档 删除过后,再通过查询接口去查询将得不到结果
url :"http://localhost:9200/singindex/music/1/'
HTTP方法采用DELETE的形式
总结:
增删改查分别对应:HTTP请求的PUT、GET、DELETE方法。PUT调用是如果不存在就是创建,已存在是更新。