没有合适的资源?快使用搜索试试~ 我知道了~
首页java-high-level-REST-client.pdf
java-high-level-REST-client.pdf
需积分: 50 10 下载量 35 浏览量
更新于2023-03-16
评论
收藏 2.4MB PDF 举报
elasticsearch7.10Java高级客户端(high-level)官方文档(英文)。 由官方文档导出的PDF格式的英文文档。high-level 是官方唯一在持续维护的java的elasticsearch客户端
资源详情
资源评论
资源推荐
Java High Level REST Client
1. Getting started
This section describes how to get started with the high-level REST client from
getting the artifact to using it in an application.
1.1. Compatibility
The Java High Level REST Client requires at least Java 1.8 and depends on the
Elasticsearch core project. The client version is the same as the Elasticsearch
version that the client was developed for. It accepts the same request arguments
as the TransportClient and returns the same response objects. See the
Section 24, “Migration Guide” if you need to migrate an application from
TransportClient to the new REST client.
The High Level Client is guaranteed to be able to communicate with any
Elasticsearch node running on the same major version and greater or equal minor
version. It doesn’t need to be in the same minor version as the Elasticsearch
nodes it communicates with, as it is forward compatible meaning that it supports
communicating with later versions of Elasticsearch than the one it was developed
for.
The 6.0 client is able to communicate with any 6.x Elasticsearch node, while the
6.1 client is for sure able to communicate with 6.1, 6.2 and any later 6.x version,
but there may be incompatibility issues when communicating with a previous
Elasticsearch node version, for instance between 6.1 and 6.0, in case the 6.1
client supports new request body fields for some APIs that are not known by the
6.0 node(s).
It is recommended to upgrade the High Level Client when upgrading the
Elasticsearch cluster to a new major version, as REST API breaking changes may
cause unexpected results depending on the node that is hit by the request, and
newly added APIs will only be supported by the newer version of the client. The
client should always be updated last, once all of the nodes in the cluster have
been upgraded to the new major version.
1
Java High Level REST Client
1.2. Javadoc
The javadoc for the REST high level client can be found at {rest-high-level-client-
javadoc}/index.html.
1.3. Maven Repository
The high-level Java REST client is hosted on Maven Central
1
. The minimum Java
version required is 1.8.
The High Level REST Client is subject to the same release cycle as Elasticsearch.
Replace the version with the desired client version.
If you are looking for a SNAPSHOT version, you should add our snapshot
repository to your Maven config:
<repositories>
<repository>
<id>es-snapshots</id>
<name>elasticsearch snapshot repo</name>
<url>https://snapshots.elastic.co/maven/</url>
</repository>
</repositories>
or in Gradle:
maven {
url "https://snapshots.elastic.co/maven/"
}
1
https://search.maven.org/search?q=g:org.elasticsearch.client
2
Java High Level REST Client
Maven configuration
Here is how you can configure the dependency using maven as a dependency
manager. Add the following to your pom.xml file:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>{version}</version>
</dependency>
Gradle configuration
Here is how you can configure the dependency using gradle as a dependency
manager. Add the following to your build.gradle file:
dependencies {
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-
client:{version}'
}
Lucene Snapshot repository
The very first releases of any major version (like a beta), might have been built on
top of a Lucene Snapshot version. In such a case you will be unable to resolve
the Lucene dependencies of the client.
For example, if you want to use the 7.0.0-beta1 version which depends on
Lucene 8.0.0-snapshot-83f9835, you must define the following repository.
For Maven:
<repository>
3
Java High Level REST Client
<id>elastic-lucene-snapshots</id>
<name>Elastic Lucene Snapshots</name>
<url>https://s3.amazonaws.com/download.elasticsearch.org/
lucenesnapshots/83f9835</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
For Gradle:
maven {
name 'lucene-snapshots'
url 'https://s3.amazonaws.com/download.elasticsearch.org/
lucenesnapshots/83f9835'
}
1.4. Dependencies
The High Level Java REST Client depends on the following artifacts and their
transitive dependencies:
• org.elasticsearch.client:elasticsearch-rest-client
• org.elasticsearch:elasticsearch
1.5. Initialization
A RestHighLevelClient instance needs a REST low-level client builder to be built
as follows:
4
Java High Level REST Client
include-tagged::{elasticsearch-root}/client/rest-high-
level/src/test/java/org/elasticsearch/client/documentation/
MiscellaneousDocumentationIT.java[rest-high-level-client-init]
The high-level client will internally create the low-level client used to perform
requests based on the provided builder. That low-level client maintains a pool of
connections and starts some threads so you should close the high-level client
when you are well and truly done with it and it will in turn close the internal low-
level client to free those resources. This can be done through the close:
include-tagged::{elasticsearch-root}/client/rest-high-
level/src/test/java/org/elasticsearch/client/documentation/
MiscellaneousDocumentationIT.java[rest-high-level-client-close]
In the rest of this documentation about the Java High Level Client, the
RestHighLevelClient instance will be referenced as client.
1.6. RequestOptions
All APIs in the RestHighLevelClient accept a RequestOptions which you can use
to customize the request in ways that won’t change how Elasticsearch executes
the request. For example, this is the place where you’d specify a NodeSelector to
control which node receives the request. See the low level client documentation
for more examples of customizing the options.
1.7. Asynchronous usage
All of the methods across the different clients exist in a traditional synchronous
and asynchronous variant. The difference is that the asynchronous ones use
asynchronous requests in the REST Low Level Client. This is useful if you are
doing multiple requests or are using e.g. rx java, Kotlin co-routines, or similar
frameworks.
The asynchronous methods are recognizable by the fact that they have the word
"Async" in their name and return a Cancellable instance. The asynchronous
methods accept the same request object as the synchronous variant and accept a
generic ActionListener<T> where T is the return type of the synchronous method.
5
剩余619页未读,继续阅读
keep-go-on
- 粉丝: 5103
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0