我需要更新或删除几个文档。
当我更新时,我这样做:
该操作一直进行到点1不再返回结果为止。
当我删除时,我这样做:
重复此操作,直到点1不再返回结果。
这是进行更新的正确方法吗?
删除时,是否可以发送多个ID一次删除多个文档?
最佳答案
对于删除和更新,如果要按ID删除或更新,可以使用批量api:
Bulk API
The bulk API makes it possible to perform many index/delete operations in a single API call. This can greatly increase the indexing speed.
The possible actions are index, create, delete and update. index and create expect a source on the next line, and have the same semantics as the op_type parameter to the standard index API (i.e. create will fail if a document with the same index and type exists already, whereas index will add or replace a document as necessary). delete does not expect a source on the following line, and has the same semantics as the standard delete API. update expects that the partial doc, upsert and script and its options are specified on the next line.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html
您也可以通过查询删除:
Delete By Query API
The delete by query API allows to delete documents from one or more indices and one or more types based on a query. The query can either be provided using a simple query string as a parameter, or using the Query DSL defined within the request body.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
关于elasticsearch - 如何使用Elasticsearch处理多个更新/删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25625066/