Skip to content

Commit

Permalink
Merge branch 'main' into licenselink
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin authored Aug 30, 2023
2 parents a8d24d2 + a898492 commit b14165c
Show file tree
Hide file tree
Showing 729 changed files with 27,061 additions and 4,481 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ html_docs

# Local Makefile
Makefile

# Temp files and directories
temp/
*Temp.java
*TempTest.java
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ The `docs/design` folder contains records of the major decisions in the design o
- Nested objects can be constructed with builder lambdas, allowing for clean and expressive DSL-like code.
- Optional values are represented as `null` with `@Nullable` annotations instead of the newer `Optional`, the Java ecosystem being still very null-based.

## Installation

Refer to the [Installation section](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_installation)
of the getting started documentation.

## Connecting

Refer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_connecting)
of the getting started documentation.

## Usage

- [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_creating_an_index)
- [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_indexing_documents)
- [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_getting_documents)
- [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_searching_documents)
- [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_updating_documents)
- [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_deleting_documents)
- [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html#_deleting_an_index)

## Documentation

Please refer to [the full documentation on elastic.co](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html) for comprehensive information.
Expand Down
4 changes: 4 additions & 0 deletions config/checkstyle/checkstyle_suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
<suppress files="client[/\\]src[/\\]main[/\\]java[/\\]co[/\\]elastic[/\\]clients[/\\]elasticsearch[^.]*\.java" checks="UnusedImports" />
<suppress files="client[/\\]src[/\\]main[/\\]java[/\\]co[/\\]elastic[/\\]clients[/\\]elasticsearch[/\\]Elasticsearch[^.]*\.java" checks="LineLength" />
<suppress files="client[/\\]src[/\\]main[/\\]java[/\\]co[/\\]elastic[/\\]clients[/\\]elasticsearch[/\\]Elasticsearch[^.]*\.java" checks="UnusedImports" />
<!-- Do not check temp files: 'temp' packages and 'FooTemp.java' files -->
<suppress files="[/\\]temp[/\\]" checks="." />
<suppress files="Temp.java*" checks="." />
<suppress files="TempTest.java*" checks="." />
</suppressions>
2 changes: 1 addition & 1 deletion config/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.10.0
8.11.0
10 changes: 8 additions & 2 deletions docs/troubleshooting/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
// * <<debugging>>
// * <<deprecation-warnings>>

.Exceptions
[discrete]
=== Exceptions

* <<missing-required-property>>
* <<serialize-without-typed-keys>>
* <<no-such-method-request-options>>

[discrete]
=== Miscellaneous

* <<serialize-without-typed-keys>>

// [[debugging]]
// === Debugging
Expand All @@ -17,4 +22,5 @@
// === Elasticsearch deprecation warnings

include::missing-required-property.asciidoc[]
include::no-such-method-request-options.asciidoc[]
include::serialize-without-typed-keys.asciidoc[]
36 changes: 36 additions & 0 deletions docs/troubleshooting/no-such-method-request-options.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

[[no-such-method-request-options]]
=== `NoSuchMethodError RequestOptions$Builder.removeHeader` when creating a client

In certain contexts you may encounter an error when creating the `ElasticsearchClient` saying that the method `RequestOptions$Builder.removeHeader` does not exist:

["source","java"]
--------------------------------------------------
java.lang.NoSuchMethodError: 'org.elasticsearch.client.RequestOptions$Builder org.elasticsearch.client.RequestOptions$Builder.removeHeader(java.lang.String)'
--------------------------------------------------

This method was introduced in `elasticsearch-rest-client` version 7.16.0. The error happens because your project is using an older version of this dependency.

This happens in particular when the project is using the https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/[Spring Boot Maven Plugin], as this plugin https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-dependencies/build.gradle[defines versions for commonly used libraries], including `elasticsearch-rest-client`. Depending on the version of Spring Boot used in the project, that version may be outdated.

To solve this issue, you have to add the `elasticsearch-rest-client` dependency explicitly in your project, with the same version as `elasticsearch-java` (see also <<installation>>).

Using Gradle:

["source","groovy",subs="attributes+"]
--------------------------------------------------
implementation 'org.elasticsearch.client:elasticsearch-rest-client:{version}'
--------------------------------------------------


Using Maven:

["source","xml",subs="attributes+"]
--------------------------------------------------
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>{version}</version>
</dependency>
--------------------------------------------------

Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
import javax.annotation.Nullable;
import javax.net.ssl.SSLException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -231,12 +231,8 @@ private String queryString(Request request, TransportOptions options) {
.entrySet()
.stream()
.map(e -> {
try {
return URLEncoder.encode(e.getKey(), "UTF-8") + "=" +
URLEncoder.encode(e.getValue(), "UTF-8");
} catch(UnsupportedEncodingException ex) {
throw new RuntimeException(ex);
}
return URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "=" +
URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8);
})
.collect(Collectors.joining("&"));
}
Expand Down
40 changes: 26 additions & 14 deletions java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import com.github.jk1.license.ProjectData
import com.github.jk1.license.render.ReportRenderer
import com.github.jk1.license.render.LicenseDataCollector
import com.github.jk1.license.render.ReportRenderer
import java.io.FileWriter

plugins {
Expand Down Expand Up @@ -53,8 +53,8 @@ tasks.getByName<ProcessResources>("processResources") {
if (name != "apis.json") {
// Only process main source-set resources (test files are large)
expand(
"version" to version,
"git_revision" to (if (rootProject.extra.has("gitHashFull")) rootProject.extra["gitHashFull"] else "unknown")
"version" to version,
"git_revision" to (if (rootProject.extra.has("gitHashFull")) rootProject.extra["gitHashFull"] else "unknown")
)
}
}
Expand All @@ -69,7 +69,7 @@ tasks.withType<Jar> {
if (rootProject.extra.has("gitHashFull")) {
val jar = this as Jar
jar.manifest.attributes["X-Git-Revision"] = rootProject.extra["gitHashFull"]
jar.manifest.attributes["X-Git-Commit-Time"] = rootProject .extra["gitCommitTime"]
jar.manifest.attributes["X-Git-Commit-Time"] = rootProject.extra["gitCommitTime"]
} else {
throw GradleException("No git information available")
}
Expand Down Expand Up @@ -154,7 +154,7 @@ publishing {
// are the same as the one used in the dependency section below.
val xPathFactory = javax.xml.xpath.XPathFactory.newInstance()
val depSelector = xPathFactory.newXPath()
.compile("/project/dependencies/dependency[groupId/text() = 'org.elasticsearch.client']")
.compile("/project/dependencies/dependency[groupId/text() = 'org.elasticsearch.client']")
val versionSelector = xPathFactory.newXPath().compile("version")

var foundVersion = false;
Expand Down Expand Up @@ -183,6 +183,7 @@ dependencies {
// the Java API client coexists with a 7.x HLRC work fine
val elasticsearchVersion = "7.17.7"
val jacksonVersion = "2.13.3"
val openTelemetryVersion = "1.29.0"

// Apache 2.0
// https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
Expand All @@ -201,6 +202,13 @@ dependencies {
// https://github.com/eclipse-ee4j/parsson
api("org.eclipse.parsson:parsson:1.0.0")

// OpenTelemetry API for native instrumentation of the client.
// Apache 2.0
// https://github.com/open-telemetry/opentelemetry-java
implementation("io.opentelemetry", "opentelemetry-api", openTelemetryVersion)
// Use it once it's stable (see Instrumentation.java). Limited to tests for now.
testImplementation("io.opentelemetry", "opentelemetry-semconv", "$openTelemetryVersion-alpha")

// EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
// https://github.com/eclipse-ee4j/jsonb-api
compileOnly("jakarta.json.bind", "jakarta.json.bind-api", "2.0.0")
Expand Down Expand Up @@ -236,6 +244,9 @@ dependencies {
// https://www.testcontainers.org/
testImplementation("org.testcontainers", "testcontainers", "1.17.3")
testImplementation("org.testcontainers", "elasticsearch", "1.17.3")


testImplementation("io.opentelemetry", "opentelemetry-sdk", openTelemetryVersion)
}


Expand All @@ -247,17 +258,18 @@ licenseReport {
class SpdxReporter(val dest: File) : ReportRenderer {
// License names to their SPDX identifier
val spdxIds = mapOf(
"Apache License, Version 2.0" to "Apache-2.0",
"The Apache Software License, Version 2.0" to "Apache-2.0",
"BSD Zero Clause License" to "0BSD",
"Eclipse Public License 2.0" to "EPL-2.0",
"Eclipse Public License v. 2.0" to "EPL-2.0",
"Eclipse Public License - v 2.0" to "EPL-2.0",
"GNU General Public License, version 2 with the GNU Classpath Exception" to "GPL-2.0 WITH Classpath-exception-2.0",
"COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" to "CDDL-1.0"
"The Apache License, Version 2.0" to "Apache-2.0",
"Apache License, Version 2.0" to "Apache-2.0",
"The Apache Software License, Version 2.0" to "Apache-2.0",
"BSD Zero Clause License" to "0BSD",
"Eclipse Public License 2.0" to "EPL-2.0",
"Eclipse Public License v. 2.0" to "EPL-2.0",
"Eclipse Public License - v 2.0" to "EPL-2.0",
"GNU General Public License, version 2 with the GNU Classpath Exception" to "GPL-2.0 WITH Classpath-exception-2.0",
"COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" to "CDDL-1.0"
)

private fun quote(str: String) : String {
private fun quote(str: String): String {
return if (str.contains(',') || str.contains("\"")) {
"\"" + str.replace("\"", "\"\"") + "\""
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
import co.elastic.clients.elasticsearch.ml.ElasticsearchMlAsyncClient;
import co.elastic.clients.elasticsearch.monitoring.ElasticsearchMonitoringAsyncClient;
import co.elastic.clients.elasticsearch.nodes.ElasticsearchNodesAsyncClient;
import co.elastic.clients.elasticsearch.query_ruleset.ElasticsearchQueryRulesetAsyncClient;
import co.elastic.clients.elasticsearch.rollup.ElasticsearchRollupAsyncClient;
import co.elastic.clients.elasticsearch.search_application.ElasticsearchSearchApplicationAsyncClient;
import co.elastic.clients.elasticsearch.searchable_snapshots.ElasticsearchSearchableSnapshotsAsyncClient;
Expand All @@ -138,6 +139,7 @@
import co.elastic.clients.elasticsearch.snapshot.ElasticsearchSnapshotAsyncClient;
import co.elastic.clients.elasticsearch.sql.ElasticsearchSqlAsyncClient;
import co.elastic.clients.elasticsearch.ssl.ElasticsearchSslAsyncClient;
import co.elastic.clients.elasticsearch.synonyms.ElasticsearchSynonymsAsyncClient;
import co.elastic.clients.elasticsearch.tasks.ElasticsearchTasksAsyncClient;
import co.elastic.clients.elasticsearch.transform.ElasticsearchTransformAsyncClient;
import co.elastic.clients.elasticsearch.watcher.ElasticsearchWatcherAsyncClient;
Expand Down Expand Up @@ -256,6 +258,10 @@ public ElasticsearchNodesAsyncClient nodes() {
return new ElasticsearchNodesAsyncClient(this.transport, this.transportOptions);
}

public ElasticsearchQueryRulesetAsyncClient queryRuleset() {
return new ElasticsearchQueryRulesetAsyncClient(this.transport, this.transportOptions);
}

public ElasticsearchRollupAsyncClient rollup() {
return new ElasticsearchRollupAsyncClient(this.transport, this.transportOptions);
}
Expand Down Expand Up @@ -292,6 +298,10 @@ public ElasticsearchSslAsyncClient ssl() {
return new ElasticsearchSslAsyncClient(this.transport, this.transportOptions);
}

public ElasticsearchSynonymsAsyncClient synonyms() {
return new ElasticsearchSynonymsAsyncClient(this.transport, this.transportOptions);
}

public ElasticsearchTasksAsyncClient tasks() {
return new ElasticsearchTasksAsyncClient(this.transport, this.transportOptions);
}
Expand All @@ -315,7 +325,7 @@ public ElasticsearchXpackAsyncClient xpack() {
* request.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/docs-bulk.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/docs-bulk.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -334,7 +344,7 @@ public CompletableFuture<BulkResponse> bulk(BulkRequest request) {
* a function that initializes a builder to create the
* {@link BulkRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/docs-bulk.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/docs-bulk.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -347,7 +357,7 @@ public final CompletableFuture<BulkResponse> bulk(Function<BulkRequest.Builder,
* request.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/docs-bulk.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/docs-bulk.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -362,7 +372,7 @@ public CompletableFuture<BulkResponse> bulk() {
* Explicitly clears the search context for a scroll.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/clear-scroll-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/clear-scroll-api.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -380,7 +390,7 @@ public CompletableFuture<ClearScrollResponse> clearScroll(ClearScrollRequest req
* a function that initializes a builder to create the
* {@link ClearScrollRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/clear-scroll-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/clear-scroll-api.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -393,7 +403,7 @@ public final CompletableFuture<ClearScrollResponse> clearScroll(
* Explicitly clears the search context for a scroll.
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/clear-scroll-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/clear-scroll-api.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -408,7 +418,7 @@ public CompletableFuture<ClearScrollResponse> clearScroll() {
* Close a point in time
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/point-in-time-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/point-in-time-api.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -426,7 +436,7 @@ public CompletableFuture<ClosePointInTimeResponse> closePointInTime(ClosePointIn
* a function that initializes a builder to create the
* {@link ClosePointInTimeRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/point-in-time-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/point-in-time-api.html">Documentation
* on elastic.co</a>
*/

Expand Down Expand Up @@ -1464,7 +1474,7 @@ public CompletableFuture<MtermvectorsResponse> mtermvectors() {
* Open a point in time that can be used in subsequent searches
*
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/point-in-time-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/point-in-time-api.html">Documentation
* on elastic.co</a>
*/

Expand All @@ -1482,7 +1492,7 @@ public CompletableFuture<OpenPointInTimeResponse> openPointInTime(OpenPointInTim
* a function that initializes a builder to create the
* {@link OpenPointInTimeRequest}
* @see <a href=
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.9/point-in-time-api.html">Documentation
* "https://www.elastic.co/guide/en/elasticsearch/reference/8.10/point-in-time-api.html">Documentation
* on elastic.co</a>
*/

Expand Down
Loading

0 comments on commit b14165c

Please sign in to comment.