The deletion of Elasticsearch is also very flexible, next time I introduce, DeleteByQuery the way. Today, we will introduce a deletion based on the ID. On the code.Package Com.sojson.core.elasticsearch.manager;Import Org.elasticsearch.action.delete.DeleteResponse;Import Com.sojson.common.model.SOBanggKey;Import Com.sojson.core.elasticsearch.utils.ESTools;public class Deletemanager {/*** Deleted by ID* @param key* @return*/public static int Deletesoban
Introduction:For children who have just come into contact with ES, they often do not understand the meaning of the various ES concepts. In particular, the word "index" is more confused with the relational database. In this paper, through the comparison of relational database, the common es in the increment, delete, change, check the operation of graphics and text rendering. Can deepen your understanding of ES. At the same time, it also lists the graph
document that deletes an index named blog with a type of Article,id 1:DeleteResponse dResponse = client.prepareDelete("blog", "article", "1").execute().actionGet();
1
2
by Deleteresponse the Isfound () method of the object, you can get the success of the deletion, and the return value is a Boolean type.Third, delete through queryelasticsearch-2.3 and older APIs are not the same, install plugins:delete-by-query
1
When a
blog with a type of Article,id 1:DeleteResponse dResponse = client.prepareDelete("blog""article""1").execute().actionGet();by Deleteresponse the Isfound () method of the object, you can get the success of the deletion, and the return value is a Boolean type.Third, delete through queryelasticsearch-2.3 and older APIs are not the same, install plugins:delete-by-queryDelete the index named Twitter, with all documents of type Tweet,user field containing
shard.The default mode is SINGLE_THREAD .Elasticsearch's Javaapi Delete by queryThe Delete by Query API allows you to delete documents based on a query, from one or more based on index and one or more type. Here is an example:Import static Org.elasticsearch.index.query.filterbuilders.*;import static org.elasticsearch.index.query.querybuilders.*;D Eletebyqueryre
= Client.preparedelete ("Twitter", "tweet", "1")
. setoperationthreaded (False)
. Execute ()
. Actionget ();
The bulk of the javaapi of Elasticsearch
The Bulk API can be used to retrieve and delete multiple data in a single request, and here is an example:
Import
Static
org
.
Elasticsearch
.
Common
.
xcontent
.
xcontentfacto
?conflicts=proceed "
The merge script is as follows:
#!/bin/sh
curl-xpost ' Http://192.168.1.101:9200/_forcemerge?
Only_expunge_deletes=truemax_num_segments=1 '6, there is no more general method.
have, use ES official website tool--curator tool. 6.1 Curator Introduction
Main purpose: To plan and manage the index of ES. Supports common operations: Create, delete, merge, Reindex, snapshot, and so on. 6.2 Curator Website Address
Http://t.cn/RuwN0oM
git
In the 2.X version, this delete by query function was removed because the official thought it would cause some errors to install the plugin itself if needed.Bin/plugin Install Delete-by-queryWhen you need to useDELETE/Index name/type/_query{"query"needed to be emptied: {"match_all " : {}}}Then in the 5.x version of the API is again the official back to the self-feature. That's what the new feature says.Dele
change, unchanged original data) "recommended"POST Index name/table/id/_update{ "Doc": { "field": Value, "field": Value }}#修改文档 (incremental modification, unmodified original data unchanged) POST jobbole/job/1/_update{ "Doc": { "comments": "City ": "Tianjin" }}8. Delete the index, delete the documentDelete index name/table/ID delete a specified d
Elasticsearch supports batch addition or deletion of index documents. In Java APIs, bulkrequestbuilder is constructed, batch index/delete requests are added to bulkrequestbuilder, and bulkrequestbuilder is executed. The following is an example:
Import static Org. elasticsearch. common. xcontent. xcontentfactory. *; bulkrequestbuilder bulkrequest = client. prepare
First, the demandYou need to implement a field in the project to delete the document and delete a property of the specified field.Take document TEST/DOCUMENT/1 as an example:{ "_index":"Test", "_type":"Document", "_id":"1", "_score":1, "_source":{ "class":"Com.test.data", "ID":1, "Items":[{"class": "Com.test.data", "ID": 1 }], "lastupdated":"2016-07-22t11:26
Elasticsearch Java API (ii): index create delete cluster managementElastic official website has the authoritative Java API English needs to be patient to see here to tidy up the basic operationCreate a MAVEN project to add dependencies First, customize a client to connect ES/*** Created by Forgeeks at 2017-03-22 18:27*/ Public classmyclient {PrivateSettings Settings; Privatetransportclient Client; Pr
(); LongThen, according to the primary key to update the ES information, which does not appear in the field to update, do not overwrite the original value.Updateresponse response = ElasticsearchConfig.client.prepareUpdate ("index", "type", "PRIMARY Key ID") . Setdoc ( Xcontentfactory.jsonbuilder (). startobject () field ("business Field 1", "2") . Field ("Busine
The delete API allows you to delete JSON documents from a specified index by ID. There are two methods: ID-based data deletion and query-based data deletion.
1. Delete by ID
The following example shows how to delete a document whose index name is Twitter, its type is tweet, and its ID is 1:
DeleteResponse response = cl
Java official documentation for the main reference el: https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/generate.html
A blog: http://www.cnblogs.com/huangfox/p/3543134.html
Elasticsearch Official Guide: http://es.xiaoleilu.com/010_Intro/30_Tutorial_Search.html
Key concepts of @xuguokun1986 code Understand the following nouns, as mentioned in the previous article, indexed (indices)-> databas
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.