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
One, based on the HTTP protocol, in JSON for the data interactive format of the RESTful APIThe components that make the request to Elasticsearch are the same as other normal HTTP requests:Curl-xVerd http method: GET POST PUT HEAD DELETEPROTOCOL http or HTTPS protocolPort Elasticsearch HTTP service, default is 9200Path API paths (for example, _count will return th
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.
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,
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
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
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
First, Cluster API detailed1, cluster health (get the status of the cluster)Cluster Status:Green: It means that all the fragments are assignedYellow: Yellow indicates that the primary fragment is assigned, but the copy is notRed: Indicates that a specific fragment is not allocated in the clusterRequest parametersLevel:cluster,indices,shardsWait_for_status:green,yellow,red[Email protected] ~]# Curl-xget ' http://10.2.11.225:9200/_cluster/health/tomcat-
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
Join the dependencyMy local Elasticsearch version is 2.1.0, so join the corresponding Maven dependencyCreate ClientThe Elasticsearch client is divided into node client and transportclient.
Node Client: Nodes themselves are nodes of the Elasticsearch cluster, as well as nodes in the Elasticsearch cluster and ot
_shards:
total:5
successful:5
failed:0 Hits:
total:1
max_score:1.0
Hits:
-_index: "Test1"
_type: "User"
_id: "1"
_score: 1.0
_source:
name: "Silence"
Pretty: Indicates whether to return the data in a JSON format in a visual format, false or not in the format of the formatting, otherwise format
Human: Indicates whether the return result is formatted, such as 3600 (s) display 1h
Query result filteringUse the Filter_path parameter mainly to set up
1. In the retu
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
This article is for the translation of official documents and personal understanding. When the author translates, the version of Elasticsearch (hereinafter referred to as ES) is 1.2.2. Please support original: http://www.cnblogs.com/donlianli/p/3836768.htmlI. Changes in statistical information-related ordersFor cluster state Cluster_state, node information Nodes_info, node statistics nodes_stats and index Information indices_stats command format are u
}/_mapping/{types}curl-xdelete Http://localhost:9200/{indices}/_alias/{names}curl-xdelete/HTTP Localhost:9200/{indices}/_warmer/{names}where {Indices},{type} and {name} can be any of the following:
_all , * or empty, these 3 values mean the same, representing all possible values
Wildcard characters, such as "test*"
Comma-delimited list, for example : index_1,test_*
The only exception is the delete command, which does not receive an empty value.If you want to delete anythin
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
filterFilterBuilder filter = FilterBuilders.termFilter("colour", "pale");TermsFacetBuilder facet = FacetBuilders.termsFacet("f") .field("brand") .facetFilter(filter); // We apply it to the facetSearchResponse sr = node.client().prepareSearch() .setQuery(QueryBuilders.matchAllQuery()) .setFilter(filter) // We apply it to the query .addFacet(facet) .execute().actionGet();ScopeBy default, facets Act on the result set of the query. However, regardless of the query, you can use global parameters
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.