Skip to content

Commit 62e9805

Browse files
committed
Updated installation instructions (#840)
1 parent 907f9d0 commit 62e9805

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,42 @@ The library is compatible with all Elasticsearch versions since 5.x, but you sho
4141
@elastic/elasticsearch@5
4242
```
4343

44+
#### Install multiple versions
45+
If you are using multiple versions of Elasticsearch, you need to use multiple versions of the client. In the past, install multiple versions of the same package was not possible, but with `npm v6.9`, you can do that via aliasing.
46+
47+
The command you must run to install different version of the client is:
48+
```sh
49+
npm install <alias>@npm:@elastic/elasticsearch@<version>
50+
```
51+
So for example if you need to install `7.x` and `6.x`, you will run
52+
```sh
53+
npm install es6@npm:@elastic/elasticsearch@6
54+
npm install es7@npm:@elastic/elasticsearch@7
55+
```
56+
And your `package.json` will look like the following:
57+
```json
58+
"dependencies": {
59+
"es6": "npm:@elastic/elasticsearch@^6.7.0",
60+
"es7": "npm:@elastic/elasticsearch@^7.0.0"
61+
}
62+
```
63+
And finally, you will require the packages from your code by using the alias you have defined.
64+
```js
65+
const { Client: Client6 } = require('es6')
66+
const { Client: Client7 } = require('es7')
67+
68+
const client6 = new Client6({ node: 'http://localhost:9200' })
69+
const client7 = new Client7({ node: 'http://localhost:9201' })
70+
71+
client6.info(console.log)
72+
client7.info(console.log)
73+
```
74+
75+
Finally, if you want to install the client for the next version of Elasticsearch *(the one that lives in Elasticsearch’s master branch)*, you can use the following command:
76+
```sh
77+
npm install esmaster@github:elastic/elasticsearch-js
78+
```
79+
4480
## Usage
4581

4682
You can find the full documentation in our [docs](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html) website.

0 commit comments

Comments
 (0)