Skip to content

Commit f459c2e

Browse files
authored
Merge pull request #33 from shelfio/feature/update-es-version-to-8.4.0
2 parents c572e9b + 78b4856 commit f459c2e

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Breaking Changes
22

3+
## 5.0.0
4+
5+
- Upgrade `@elastic/elasticsearch` to version 8.4.0
6+
- Changed `getDocuments` request parameters according to the new Elasticsearch version
7+
- use `getDocuments({index, {query: {}})` instead of `getDocuments({index, body: {query: {}}})`
8+
- Run Elasticsearch >= `v8.0.0` locally requires java `v17`/`v18`. See [Support Matrix](https://www.elastic.co/support/matrix#matrix_jvm)
9+
310
## 4.0.0
411

512
- Upgrade `jest` to version 28

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If you have a custom `jest.config.js` make sure you remove `testEnvironment` pro
2525
```js
2626
module.exports = () => {
2727
return {
28-
esVersion: '7.6.0', // ! must be exact version. Ref: https://github.com/elastic/elasticsearch-js .
28+
esVersion: '8.4.0', // ! must be exact version. Ref: https://github.com/elastic/elasticsearch-js .
2929
// don't be shy to fork our code and update deps to correct.
3030
clusterName: 'your-cluster-name',
3131
nodeName: 'your-node-name',
@@ -84,14 +84,14 @@ The main reason why this issue appears is that you have an incompatible java ver
8484
$ /usr/libexec/java_home -V
8585
```
8686
87-
2. If you see version 1.8.xxx
87+
2. If you see version 18.0.x
8888
Add this command to your bashrc, zshrc, etc
8989
```shell
90-
$ /usr/libexec/java_home -v 1.8
90+
$ /usr/libexec/java_home -v 18
9191
```
9292
93-
3. If you see no versions or do not have a compatible version installed - Install version 1.8xxx
94-
https://www.java.com/en/download/
93+
3. If you see no versions or do not have a compatible version installed - Install version 18
94+
https://www.oracle.com/java/technologies/downloads/#java18
9595
9696
4. Reload the console and check the java version with
9797
```shell
@@ -100,12 +100,14 @@ $ java -version
100100
Output for proper work
101101
```shell
102102
$ java -version
103-
java version "1.8.0_333"
104-
Java(TM) SE Runtime Environment (build 1.8.0_333-b02)
105-
Java HotSpot(TM) 64-Bit Server VM (build 25.333-b02, mixed mode)
103+
java version "18.0.2.1"
104+
Java(TM) SE Runtime Environment (build 18.0.2.1+1-1)
105+
Java HotSpot(TM) 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)
106106
```
107107
108-
5. Go to step 2 and set version 1.8xx as a default for the shell
108+
5. Go to step **2** and set version 18.xx as a default for the shell
109+
110+
> Note: If you need to run elastic <= `v7.17.x` locally, then perform the steps above but for the java version 1.8.xxx
109111
110112
111113
</details>

jest-es-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const documentsMapping = require('./index-mapping');
22

33
module.exports = function getClusterSetting() {
44
return {
5-
esVersion: '8.2.0',
5+
esVersion: '8.4.0',
66
clusterName: 'docs',
77
nodeName: 'docs',
88
port: 9200,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
"preset": "./jest-preset.js"
5050
},
5151
"dependencies": {
52-
"@shelf/elasticsearch-local": "3.0.0",
52+
"@shelf/elasticsearch-local": "3.2.0",
5353
"cwd": "0.10.0"
5454
},
5555
"devDependencies": {
5656
"@babel/cli": "7.18.9",
5757
"@babel/core": "7.18.9",
58-
"@elastic/elasticsearch": "7.15.0",
58+
"@elastic/elasticsearch": "8.4.0",
5959
"@shelf/babel-config": "1.2.0",
6060
"@shelf/eslint-config": "0.19.0",
6161
"@shelf/prettier-config": "0.0.7",

tests/elasticsearch.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
import {Client} from '@elastic/elasticsearch';
2-
import {
3-
ApiResponse,
4-
TransportRequestOptions,
5-
TransportRequestPromise
6-
} from '@elastic/elasticsearch/lib/Transport';
1+
import {Client, estypes as EsTypes} from '@elastic/elasticsearch';
72

83
let client: undefined | Client;
94

10-
export function search(options: TransportRequestOptions): TransportRequestPromise<ApiResponse> {
5+
export function search(options: EsTypes.SearchRequest): Promise<EsTypes.SearchResponse> {
116
const es = getClient();
127

13-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
14-
// @ts-ignore
158
return es.search(options);
169
}
1710

18-
export async function refreshAllIndexes(): Promise<TransportRequestPromise<ApiResponse>> {
11+
export async function refreshAllIndexes(): Promise<EsTypes.IndicesRefreshResponse> {
1912
const es = getClient();
2013

2114
return es.indices.refresh({index: '_all'});

tests/search-by-term.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import {estypes as EsTypes} from '@elastic/elasticsearch';
12
import {search} from './elasticsearch';
23

34
type GetDocumentsResponse = {
4-
items: Array<{[key: string]: string}>;
5-
totalCount: number;
5+
items: EsTypes.SearchHit[];
6+
totalCount: EsTypes.SearchHitsMetadata['total'];
67
};
78

89
export default async function getDocuments({
@@ -12,7 +13,7 @@ export default async function getDocuments({
1213
}: {
1314
index: string;
1415
id: string;
15-
startFrom: number;
16+
startFrom?: number;
1617
}): Promise<GetDocumentsResponse> {
1718
const body = {
1819
_source: {
@@ -28,10 +29,8 @@ export default async function getDocuments({
2829
};
2930

3031
const {
31-
body: {
32-
hits: {hits, total}
33-
}
34-
} = await search({index, body});
32+
hits: {hits, total}
33+
} = await search({index, ...body});
3534

3635
return {items: hits, totalCount: total};
3736
}

0 commit comments

Comments
 (0)