Text mode batch update multiple fields
The simplest use of an update request is to add new data. The new data is merged into the existing data, and if the same field exists, it is replaced by the new data. For example, we can add tags and views fields for our blog:
Post/website/blog/1/_update
{
"doc": {"
tags": ["Testing"],
"views": 0
}
}
If the request succeeds, we receive an index-li
In the afternoon try to use Elasticsearch Java client to do data retrieval work, test the batch update, the code is as follows: Public Static voidBulkupdategoods (listthrowsIOException, Interruptedexception, executionexception {client client=NULL; Try{Client=Transportclient.builder (). Build (). Addtransportaddress (NewInetsockettransportaddress (Inetaddress.getbyname ("Hadoop-slave4"), 9300)); } Catch(Exce
The equivalent of a memo, I feel that the memory is not good, I do some time may not remember clearly, so write a note to forget
1. First is the ES configuration because it involves scripting to update
You need to add the following configuration to the Elasticsearch configuration file elasticsearch.yml:
Script.engine.groovy.inline.update:on
2. The two scripts that are locally updated are actual business sc
/*** Update operation to update the value of field under a _id* @throws IOException*/public static void Updatedoc () throws IOException {Updaterequest updaterequest = new Updaterequest ("mytest11", "Infor2", "avysxg3et--xjju4w71o")//index,type,_id respectively. doc (Jsonbuilder (). StartObject (). Field ("Email", "999")//update field for email. EndObject ());try
(); 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
When I execute:
Curl-xpost ' localhost:9200/test/type1/1/_update '-d ' {
"script": "Ctx._source.text = \" Some text\ ""} "
Elasticsearch scripts of type [inline] was present, operation [UPDATE] and Lang [groovy] are disabled such errors
Solution added in Elasticsearch.yml
Script.inline:on
Script.indexed:on
Reboot can
Original:
Exception in thread "main" java.lang.IllegalArgumentException:sc
(searching Engine object)lagou._id = 1 #自定义ID, it is important to follow the ID to operate later Lagou.title = self[' title '] # field name = value lagou.description = self[' description '] lagou.keywords = self[' Keywords '] lagou.url = self[' url '] Lagou.riqi = self[' Riqi '] lagou.save () # writes data to Elasticsearch ( Search engine objects)2 Delete specifi
problems and more.InstallationTake the Windows operating system and the ES0.19.7 version as an example:① Download Elasticsearch-0.19.7.zip② extract directly to a directory, set the directory as Es_home environment variable③ Installing the JDK and setting the JAVA_HOME environment variable ④ under Windows, run%es_home%\bin\elasticsearch.bat to runDistributed search Elasticsearch stand-alone and server envir
Elasticsearch official documentation, data is inserted using a restful interface, which is an incremental update. When the amount of data is very large, it can be very time-consuming to traverse the full table to rebuild an index. And Elasticsearch-rivel-mysql This project is not very reliable, developers have even been on git to mark deprecated (not now). Anywa
Tags: Front remove network general multi-tenant node work HTTPS problemOriginal address: http://blog.csdn.net/w12345_ww/article/details/52182264. Copyright belongs to the original authorThese two days in the project to involve the use of elasticsearch, on the internet to search for some of this information, found that Elasticsearch installation is divided into single-machine and cluster two ways. In this ex
. It is required to update the doc nodes in the document.
{ '_op_type': 'delete', '_index': 'index-name', '_type': 'document', '_id': 42,}{ '_op_type': 'update', '_index': 'index-name', '_type': 'document', '_id': 42, 'doc': {'question': 'The life, universe and everything.'}}
Common Errors
SerializationError: JSON data serialization error, usually because the data type of a node value is not sup
.# "Number_of_shards" can be configured only once for an index## The "number_of_replicas" can be increased or decreased anytime,# By using the Index Update Settings API.# "Number_of_replicas" can be increased or decreased at any time. This can be done through the Index Update Settings (Index Update Configuration) API.### Elas
Getting started with Elasticsearch, elasticsearch
Elasticsearch is a highly scalable open-source full-text search and analysis engine. It can store, search, and analyze large-scale data quickly and in near real time. It is generally used as the underlying engine/technology to provide powerful support for applications with complex search functions and requirements
://192.168.1.1:9200/gocc/_search?pretty-d '{"Query":{"term":{"id": A}}}'{"took": +,"Timed_out":false,"_shards": {"Total":8,"Successful":8,"Failed":0},"hits": {"Total":0,"Max_score":NULL,"hits": [ ] }}
4 Summary
Validation discovery:(1) Go-mysql-elasticsearch plug-in can be synchronized insert, UPDATE, delete operation.(2) The visualization does not do well, there is no print log.(3) Go-mysql-
://192.168.1.1:9200/gocc/_search?pretty-d '{"Query":{"term":{"id": A}}}'{"took": +,"Timed_out":false,"_shards": {"Total":8,"Successful":8,"Failed":0},"hits": {"Total":0,"Max_score":NULL,"hits": [ ] }}
4 Summary
Validation discovery:(1) Go-mysql-elasticsearch plug-in can be synchronized insert, UPDATE, delete operation.(2) The visualization does not do well, there is no print log.(3) Go-mysql-
://192.168.1.1:9200/gocc/_search?pretty-d '{"Query":{"term":{"id": A}}}'{"took": +,"Timed_out":false,"_shards": {"Total":8,"Successful":8,"Failed":0},"hits": {"Total":0,"Max_score":NULL,"hits": [ ] }}
4 Summary
Validation discovery:(1) Go-mysql-elasticsearch plug-in can be synchronized insert, UPDATE, delete operation.(2) The visualization does not do well, there is no print log.(3) Go-mysql-
optimistic lock. avi
Section 20: Distributed Document System-illustration of how Elasticsearch implements optimistic lock concurrency control based on _ version. avi
Section 21: Distributed Document System-hands-on drills for optimistic lock concurrency control based on _ version. avi
Section 22: Distributed Document System-hands-on drills for optimistic lock concurrency control based on external version. avi
Section 23: Distributed Document System-i
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.