Skip to content

Commit 1b12e3d

Browse files
authored
Merge pull request #10 from hyper63/twilson63/bug-bulk-command-should-8
fix: return ok:true for each item in bulk results #8
2 parents 8bec211 + a52d7f3 commit 1b12e3d

File tree

8 files changed

+76
-11
lines changed

8 files changed

+76
-11
lines changed

Diff for: .github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: Test
22

33
on:
44
push:
5-
branches: '**'
6-
tags-ignore: '*'
5+
branches: "**"
6+
tags-ignore: "*"
77

88
jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
deno-version: [1.11.x]
13+
deno-version: [1.x]
1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: Use Deno ${{ matrix.deno-version }}

Diff for: README.md

+24
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Features](#features)
1717
- [Methods](#methods)
1818
- [Contributing](#contributing)
19+
- [Testing](#testing)
1920
- [License](#license)
2021

2122
## Getting Started
@@ -65,6 +66,29 @@ This adapter fully implements the Search port and can be used as the
6566

6667
See the full port [here](https://nest.land/package/hyper-port-search)
6768

69+
## Testing
70+
71+
- Spin up docker image locally
72+
73+
```sh
74+
docker run \
75+
-p 9200:9200 -p 9600:9600 \
76+
-e "discovery.type=single-node" \
77+
-v /workspace/hyper-adapter-elasticsearch/scripts/opensearch.yml:/usr/share/opensearch/config/opensearch.yml \
78+
opensearchproject/opensearch:1.2.3
79+
```
80+
81+
- Run hyper
82+
83+
```sh
84+
./scripts/hyper.sh
85+
```
86+
87+
- Run hyper-test
88+
89+
```
90+
```
91+
6892
## Contributing
6993

7094
Contributions are welcome! See the hyper

Diff for: adapter.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@ export default function ({ config, asyncFetch, headers, handleResponse }) {
268268
)
269269
.bichain(
270270
handleRejectedResponse,
271-
(res) => Async.Resolved({ ok: true, results: res.items }),
271+
(res) =>
272+
Async.Resolved({
273+
ok: true,
274+
results: map((o) => ({ ok: true, id: o.index._id }), res.items),
275+
}),
272276
)
273277
.toPromise();
274278
}
@@ -310,10 +314,10 @@ export default function ({ config, asyncFetch, headers, handleResponse }) {
310314
// Success
311315
(res) =>
312316
Async.Resolved(
313-
({
317+
{
314318
ok: true,
315319
matches: pluck("_source", res.hits.hits),
316-
}),
320+
},
317321
),
318322
)
319323
.toPromise();

Diff for: adapter_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ Deno.test("bulk", async () => {
175175
// bulk operation
176176
stubResponse(200, {
177177
items: [
178-
DOC1,
179-
DOC2,
178+
{ index: { _id: DOC1.id, ...DOC1 } },
179+
{ index: { _id: DOC2.id, ...DOC2 } },
180180
],
181181
});
182182

Diff for: scripts/hyper.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import hyper from "https://x.nest.land/[email protected]/mod.js";
2+
import app from "https://x.nest.land/[email protected]/mod.js";
3+
4+
import search from "../mod.js";
5+
6+
await hyper({
7+
app,
8+
adapters: [
9+
{
10+
port: "search",
11+
plugins: [
12+
search({
13+
url: "http://localhost:9200",
14+
username: "admin",
15+
password: "admin",
16+
}),
17+
],
18+
},
19+
],
20+
});

Diff for: scripts/hyper.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deno run -A --unstable --no-check ./scripts/hyper.js

Diff for: scripts/opensearch.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cluster.name: docker-cluster
2+
3+
# Bind to all interfaces because we don't know what IP address Docker will assign to us.
4+
network.host: 0.0.0.0
5+
6+
# # minimum_master_nodes need to be explicitly set when bound on a public IP
7+
# # set to 1 to allow single node clusters
8+
# discovery.zen.minimum_master_nodes: 1
9+
10+
# Setting network.host to a non-loopback address enables the annoying bootstrap checks. "Single-node" mode disables them again.
11+
#discovery.type: single-node
12+
13+
######## Start OpenSearch Security Demo Configuration ########
14+
# WARNING: revise all the lines below before you go into production
15+
plugins.security.disabled: true
16+
17+
node.max_local_storage_nodes: 3
18+
######## End OpenSearch Security Demo Configuration ########

Diff for: scripts/test.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/usr/bin/env bash
22

3-
deno lint
4-
deno fmt --check
5-
deno test
3+
deno lint && deno fmt --check && deno test

0 commit comments

Comments
 (0)