Skip to content

Commit ad6f56c

Browse files
authored
Doc updates (#791)
Updates for better displaying the documentation in the website.
1 parent 46bd14a commit ad6f56c

23 files changed

+516
-231
lines changed

docs/authentication.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
= Authentication
1+
== Authentication
22

33
This document contains code snippets to show you how to connect to various Elasticsearch providers.
44

5-
== Basic Auth
5+
=== Basic Auth
66

77
You can provide your credentials in the node(s) URL.
88

@@ -29,7 +29,7 @@ const client = new Client({
2929
})
3030
----
3131

32-
== SSL configuration
32+
=== SSL configuration
3333

3434
Without any additional configuration you can specify `https://` node urls, but the certificates used to sign these requests will not verified (`rejectUnauthorized: false`). To turn on certificate verification you must specify an `ssl` object either in the top level config or in each host config object and set `rejectUnauthorized: true`. The ssl config object can contain many of the same configuration options that https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[tls.connect()] accepts.
3535

@@ -45,7 +45,7 @@ const client = new Client({
4545
})
4646
----
4747

48-
== Elastic Cloud
48+
=== Elastic Cloud
4949

5050
If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers a easy way to connect to it via the `cloud` option. +
5151
You must pass the Cloud ID that you can find in the cloud console, then your username and password.

docs/breaking-changes.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Breaking changes coming from the old client
1+
== Breaking changes coming from the old client
22

33
If you were already using the previous version of this client --i.e. the one you used to install with `npm install elasticsearch`-- you will encounter some breaking changes.
44

docs/child.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Creating a child client
1+
== Creating a child client
22

33
There are some use cases where you may need multiple instances of the client. You can easily do that by calling `new Client()` as many times as you need, but you will lose all the benefits of using one single client, such as the long living connections and the connection pool handling. +
44
To avoid this problem the client offers a `child` API, which returns a new client instance that shares the connection pool with the parent client. +

docs/configuration.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Client configuration
1+
== Client configuration
22

33
The client is designed to be easily configured as you see fit for your needs, following you can see all the possible basic options that you can use to configure it.
44

@@ -14,7 +14,7 @@ const client = new Client({
1414
})
1515
----
1616

17-
== Basic options
17+
=== Basic options
1818
[cols=2*]
1919
|===
2020
|`node` or `nodes`
@@ -72,7 +72,7 @@ _Default:_ `false`
7272

7373
|`resurrectStrategy`
7474
|`string` - Configure the node resurrection strategy. +
75-
_Options:_ `'ping'`, `'optimistic'`, `'none'` +
75+
_Options:_ `'ping'`, `'optimistic'`, `'none'` +
7676
_Default:_ `'ping'`
7777

7878
|`suggestCompression`
@@ -122,7 +122,7 @@ function nodeSelector (connections) {
122122
----
123123
|===
124124

125-
== Advanced configuration
125+
=== Advanced configuration
126126
If you need to customize the client behavior heavily, you are in the right place! +
127127
The client allows you to customize the following internals:
128128

docs/examples/asStream.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[[as_stream_examples]]
12
== asStream
23

34
Instead of getting the parsed body back, you will get the raw Node.js stream of data.

docs/examples/bulk.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Bulk
1+
[[bulk_examples]]
2+
== Bulk
23

34
The `bulk` API makes it possible to perform many index/delete operations in a single API call. +
45
This can greatly increase the indexing speed.

docs/examples/exists.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Exists
1+
[[exists_examples]]
2+
== Exists
23

34
Check that the document `/game-of-thrones/1` exists.
45

docs/examples/get.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Get
1+
[[get_examples]]
2+
== Get
23

34
The get API allows to get a typed JSON document from the index based on its id. +
45
The following example gets a JSON document from an index called `game-of-thrones`, under a type called `_doc`, with id valued `'1'`.

docs/examples/ignore.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[[ignore_examples]]
12
== Ignore
23
HTTP status codes which should not be considered errors for this request.
34

docs/examples/index.asciidoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[[examples]]
2+
= Examples
3+
4+
Following you can find some examples on how to use the client.
5+
6+
* Use of the <<as_stream_examples,asStream>> parameter;
7+
* Executing a <<bulk_examples,bulk>> request;
8+
* Executing a <<exists_examples,exists>> request;
9+
* Executing a <<get_examples,get>> request;
10+
* Use of the <<ignore_examples,ignore>> parameter;
11+
* Executing a <<msearch_examples,msearch>> request;
12+
* How do I <<scroll_examples,scroll>>?
13+
* Executing a <<search_examples,search>> request;
14+
* I need <<suggest_examples,suggestions>>;
15+
* How to use the <<transport_request_examples,transport.request>> method;
16+
* How to use <<typescript_examples,TypeScript>>;
17+
18+
include::asStream.asciidoc[]
19+
include::bulk.asciidoc[]
20+
include::exists.asciidoc[]
21+
include::get.asciidoc[]
22+
include::ignore.asciidoc[]
23+
include::msearch.asciidoc[]
24+
include::scroll.asciidoc[]
25+
include::search.asciidoc[]
26+
include::suggest.asciidoc[]
27+
include::transport.request.asciidoc[]
28+
include::typescript.asciidoc[]

docs/examples/msearch.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= MSearch
1+
[[msearch_examples]]
2+
== MSearch
23

34
The multi search API allows to execute several search requests within the same API.
45

docs/examples/scroll.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Scroll
1+
[[scroll_examples]]
2+
== Scroll
23

34
While a search request returns a single “page” of results, the scroll API can be used to retrieve large numbers of results (or even all results) from a single search request, in much the same way as you would use a cursor on a traditional database.
45

docs/examples/search.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Search
1+
[[search_examples]]
2+
== Search
23

34
The `search` API allows you to execute a search query and get back search hits that match the query. +
45
The query can either be provided using a simple https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-uri-request.html[query string as a parameter], or using a https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-request-body.html[request body].

docs/examples/suggest.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Suggest
1+
[[suggest_examples]]
2+
== Suggest
23

34
The suggest feature suggests similar looking terms based on a provided text by using a suggester. _Parts of the suggest feature are still under development._
45

docs/examples/transport.request.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= transport.request
1+
[[transport_request_examples]]
2+
== transport.request
23

34
It can happen that you need to communicate with Elasticsearch by using an API that is not supported by the client, to mitigate this issue you can directly call `client.transport.request`, which is the internal utility that the client uses to communicate with Elasticsearch when you use an API method.
45

docs/examples/typescript.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
= Typescript
1+
[[typescript_examples]]
2+
== Typescript
23

34
The client offers a first-class support for TypeScript, since it ships the type definitions for every exposed API.
45

docs/extend.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Extend the client
1+
== Extend the client
22

33
Sometimes you need to reuse the same logic, or you want to build a custom API to allow you simplify your code. +
44
The easiest way to achieve that is by extending the client.

docs/index.asciidoc

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,12 @@
11
= @elastic/elasticsearch
22

3-
The official Node.js client for Elasticsearch.
4-
5-
== Features
6-
* One-to-one mapping with REST API.
7-
* Generalized, pluggable architecture.
8-
* Configurable, automatic discovery of cluster nodes.
9-
* Persistent, Keep-Alive connections.
10-
* Load balancing (with pluggable selection strategy) across all available nodes.
11-
* TypeScript support out of the box.
12-
13-
== Install
14-
[source,sh]
15-
----
16-
npm install @elastic/elasticsearch
17-
----
18-
By default the latest version of the module will be installed, which is the same version of the current release of Elasticsearch. +
19-
If you need to work with older versions of Elasticsearch, you should install the same version of the client as well. +
20-
For example, if you are using Elasticsearch `v6.5.4`, you will need the client `v6`, and you can easily do that with `npm install @elastic/elasticsearch@6`.
21-
22-
== Usage
23-
[source,js]
24-
----
25-
const { Client } = require('@elastic/elasticsearch')
26-
const client = new Client({ node: 'http://localhost:9200' })
27-
28-
// promise API
29-
const result = await client.search({
30-
index: 'my-index',
31-
body: { foo: 'bar' }
32-
})
33-
34-
// callback API
35-
client.search({
36-
index: 'my-index',
37-
body: { foo: 'bar' }
38-
}, (err, result) => {
39-
if (err) console.log(err)
40-
})
41-
----
42-
43-
== Reference
44-
* Client configuration
45-
* Client usage
46-
* API methods
47-
* TypeScript support
48-
* Extend the client
49-
* Breaking changes from old client
50-
* Authentication
51-
* Child client
3+
include::introduction.asciidoc[]
4+
include::usage.asciidoc[]
5+
include::configuration.asciidoc[]
6+
include::reference.asciidoc[]
7+
include::breaking-changes.asciidoc[]
8+
include::authentication.asciidoc[]
9+
include::child.asciidoc[]
10+
include::extend.asciidoc[]
11+
include::typescript.asciidoc[]
12+
include::examples/index.asciidoc[]

docs/introduction.asciidoc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
== Introduction
2+
3+
The official Node.js client for Elasticsearch.
4+
5+
=== Features
6+
* One-to-one mapping with REST API.
7+
* Generalized, pluggable architecture.
8+
* Configurable, automatic discovery of cluster nodes.
9+
* Persistent, Keep-Alive connections.
10+
* Load balancing (with pluggable selection strategy) across all available nodes.
11+
* TypeScript support out of the box.
12+
13+
=== Install
14+
[source,sh]
15+
----
16+
npm install @elastic/elasticsearch
17+
----
18+
19+
=== Compatibility
20+
21+
The library is compatible with all Elasticsearch versions since 5.x, but you should use the same major version of the Elasticsearch instance that you are using.
22+
----
23+
# Elasticsearch 7.x
24+
@elastic/elasticsearch@7
25+
26+
# Elasticsearch 6.x
27+
@elastic/elasticsearch@6
28+
29+
# Elasticsearch 5.x
30+
@elastic/elasticsearch@5
31+
----
32+
33+
=== Usage
34+
[source,js]
35+
----
36+
const { Client } = require('@elastic/elasticsearch')
37+
const client = new Client({ node: 'http://localhost:9200' })
38+
39+
// promise API
40+
const result = await client.search({
41+
index: 'my-index',
42+
body: { foo: 'bar' }
43+
})
44+
45+
// callback API
46+
client.search({
47+
index: 'my-index',
48+
body: { foo: 'bar' }
49+
}, (err, result) => {
50+
if (err) console.log(err)
51+
})
52+
----

0 commit comments

Comments
 (0)