Elasticsearch-->java REST Client API Overview:
Elasticsearch provides the rest web API, so developers can call Elasticsearch in their own restful web
For a detailed description of the Java Rest client API, see the off
Chapter ContentConnect to a local or remote Elasticsearch cluster using the client object.Index documents individually or in batches.Updates the contents of the document.Use a variety of Elasticsearch supported query methods.Handles the error message returned by the Elasticsearch.Collect cluster state information or perform administrative tasks by sending various management directives.
8.3 Connect to c
processing index. If you need to put a string as a whole to be indexed, this field needs to be set: Field ("Index", "not_analyzed").Index data /** * Bulk Index */@Test public void Indexdata () {Bulkrequestbuilder Requestbuilder = Client.preparebu LK (); for (person person:personlist) {String obj = getindexdatafromhotspotdata (person); if (obj! = null) {Requestbuilder.add (Client.prepareindex ("Test_index", "Test", String.valueof (Person.getid ())) . Setrefresh (T
We have started elasticsearch in the previous article, and then we can communicate with elasticsearch, such as inserting data, retrieving data, deleting data, and so on. Elasticsearch provides two ways to communicate with Java APIs and restful APIs. Java API
If you are using the Java,
Java API implementationsJar Package Import Please refer to the previous blog Elasticsearch 5.X under the Java API Usage guideWrite a test class:Package Esjavapia5;Import Java. NET. InetAddress;Import Java. NET. Unknownhostexception;import org. Elasticsearch. Action. Search. SearchResponse;import org.
ElasticSearch JAVA API Official document: Https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-index.htmlFirst, generate JSONThe first step in creating an index is to convert the object to a JSON string. There are four ways to create JSON documents:1.1 Handwriting Style generationString json
This blog provides an easy way for Elasticsearch to index multiple documents. The support of Bulk API can implement batch add, delete, update and so on once request. The bulk operation uses the UDP protocol, and UDP cannot ensure that data is not lost when communicating with the Elasticsearch server.First, Bulk APIWith the bulk command, the REST
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 cluster has multiple nodes, each node needs
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 kimchy:DELETE /twitter/tweet/_query?q=user:ki
Elasticsearch provides developers with a set of restful interfaces based on the HTTP protocol, and only needs to construct a rest request and parse the JSON returned by the request for access to the Elasticsearch server. Elasticsearch API interface is rich in functionality, including clustering, monitoring, deployment
By adding search data through the rest API, reading the official documentation reveals that Elasticsearch supports dynamic mapping, but there are a lot of questions and listen slowly.
This article mainly tells about three points content:
1 Elasticsearch Common REST API
2
Xcontentfactory.jsonbuilder () each type will be converted to byte[], So if the object is already in this form and can be used directly, Jsonbuilder is a highly optimized JSON generator that constructs byte[] to explain four methods through the following code:
Index-api, Get-api, Delete-api, Update-api
/** * Es-
Environment
Centos 7.4
Python 2.7
PIP 2.7 Mysql-python 1.2.5 Elasticsearc 6.3.1
Elasitcsearch6.3.2
Knowledge points
Calling the Python Elasticsearh API
Python MYSQLDB Use
DSL Query and Aggregation
Pyehon list Operations
Code#!/usr/bin/env python#-*-coding:utf-8-*-#minyt 2018.9.1# Get the number of modules that occur within 24 hours # The program obtains the relevant refinement data through the
This blog describes an easy way to index multiple documents Elasticsearch. The support of the Bulk API enables you to perform batch additions, deletions, updates, and so on at one time. The bulk operation uses the UDP protocol, and UDP cannot ensure that data is not lost when communicating with the Elasticsearch server. First, Bulk
Use of Java APIs in Elasticsearch 6.01: Create Elasticsearch client using Java API PackageCom.search.elasticsearch;Importorg.elasticsearch.client.transport.TransportClient;Importorg.elasticsearch.common.settings.Settings;Importorg.elasticsearch.common.transport.TransportAddress;Importorg.elasticsearch.transport.client.PreBuiltTransportClient;Importjava.io.IOExcep
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.