forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Update with the latest changes and use compilable examples (op…
…ensearch-project#52) (opensearch-project#53) Co-authored-by: István Zoltán Szabó <istvan.szabo@elastic.co>
- Loading branch information
1 parent
4f3a394
commit 0beaf13
Showing
10 changed files
with
221 additions
and
200 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,39 @@ | ||
[[connecting]] | ||
== Connecting | ||
|
||
beta[] | ||
The {java-client} is structured around three main components: | ||
|
||
The Java client is structured around three main components: | ||
|
||
* **API client classes**. These provide strongly typed data structures and | ||
methods for {es} APIs. Since the {es} API is large, it is structured in feature | ||
groups (also called “namespaces”), each having its own client class. {es} core | ||
* **API client classes**. These provide strongly typed data structures and | ||
methods for {es} APIs. Since the {es} API is large, it is structured in feature | ||
groups (also called “namespaces”), each having its own client class. {es} core | ||
features are implemented in the `ElasticsearchClient` class. | ||
* **A JSON object mapper**. This maps your application classes to JSON and | ||
* **A JSON object mapper**. This maps your application classes to JSON and | ||
seamlessly integrates them with the API client. | ||
* **A transport layer implementation**. This is where all HTTP request handling | ||
* **A transport layer implementation**. This is where all HTTP request handling | ||
takes place. | ||
|
||
This code snippet creates and wires together these three components: | ||
|
||
["source","java"] | ||
-------------------------------------------------- | ||
// Create the low-level client | ||
RestClient restClient = RestClient.builder( | ||
new HttpHost("localhost", 9200)).build(); | ||
// Create the transport with a Jackson mapper | ||
Transport transport = new RestClientTransport( | ||
restClient, new JacksonJsonpMapper()); | ||
// And create the API client | ||
ElasticsearchClient client = new ElasticsearchClient(transport); | ||
include-tagged::{doc-tests}/ConnectingTest.java[create-client] | ||
-------------------------------------------------- | ||
|
||
Authentication is managed by the <<java-rest-low>>. For further details on | ||
configuring authentication, refer to | ||
Authentication is managed by the <<java-rest-low>>. For further details on | ||
configuring authentication, refer to | ||
{java-api-client}/_basic_authentication.html[its documentation]. | ||
|
||
[discrete] | ||
=== Your first request | ||
|
||
The code snippet below searches all items from a “product” index whose name | ||
The code snippet below searches all items from a “product” index whose name | ||
matches “bicycle” and return them as instances of a `Product` application class. | ||
|
||
It illustrates the use of fluent functional builders to write search queries as | ||
concise DSL-like code. This pattern is explained in more detail in | ||
It illustrates the use of fluent functional builders to write search queries as | ||
concise DSL-like code. This pattern is explained in more detail in | ||
<<api-conventions>>. | ||
|
||
["source","java"] | ||
-------------------------------------------------- | ||
SearchResponse<Product> search = client.search(s -> s | ||
.index("products") | ||
.query(q -> q | ||
.term(t -> t | ||
.field("name") | ||
.value("bicycle") | ||
)), | ||
Product.class); | ||
for (Hit<AppData> hit: search.hits().hits()) { | ||
processAppData(hit.source()); | ||
} | ||
include-tagged::{doc-tests}/ConnectingTest.java[first-request] | ||
-------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Allow building docs locally without a checkout of the Elasticsearch repo | ||
:elasticsearch-root: {docdir}/local/elasticsearch | ||
|
||
include::index.asciidoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This directory contains stubs that allow building the Java client docs in isolation following the instructions in "[Building documentation for a local repo](https://github.com/elastic/docs#building-documentation)". |
4 changes: 4 additions & 0 deletions
4
docs/local/elasticsearch/docs/java-rest/low-level/index.asciidoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[[java-rest-low]] | ||
== Java Low Level REST Client | ||
|
||
This is a stub for the Java Low Level REST Client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters