Skip to content

Commit

Permalink
updating rest api spec and adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke committed Nov 10, 2023
1 parent c6e2216 commit 83f5efe
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@
"GET",
"POST"
]
},
{
"path":"/_ingest/{index}/_simulate",
"methods":[
"GET",
"POST"
],
"parts":{
"index":{
"type":"string",
"description":"Default index for docs which don't provide one"
}
}
}
]
},
"params":{
"index":{
"type":"string",
"description":"The default index to ingest all documents into if no index is given for a particular document"
},
"pipeline":{
"type":"string",
"description":"The pipeline id to preprocess incoming documents with if no pipeline is given for a particular document"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ setup:
{
"docs": [
{
"_index": "index",
"_index": "index-1",
"_id": "id",
"_source": {
"foo": "bar"
}
},
{
"_index": "index",
"_index": "index-2",
"_id": "id",
"_source": {
"foo": "rab"
Expand All @@ -33,8 +33,10 @@ setup:
]
}
- length: { docs: 2 }
- match: { docs.0.doc._index: "index-1" }
- match: { docs.0.doc._source.foo: "bar" }
- match: { docs.0.doc.executed_pipelines: [] }
- match: { docs.1.doc._index: "index-2" }
- match: { docs.1.doc._source.foo: "rab" }
- match: { docs.1.doc.executed_pipelines: [] }

Expand Down Expand Up @@ -248,3 +250,89 @@ setup:
}
}
- match: { status: 500 }

---
"Test index in path":

- skip:
features: headers

- do:
headers:
Content-Type: application/json
simulate.ingest:
index: "test-index"
body: >
{
"docs": [
{
"_id": "id",
"_source": {
"foo": "bar"
}
},
{
"_id": "id",
"_source": {
"foo": "rab"
}
}
]
}
- length: { docs: 2 }
- match: { docs.0.doc._index: "test-index" }
- match: { docs.0.doc._source.foo: "bar" }
- match: { docs.0.doc.executed_pipelines: [] }
- match: { docs.1.doc._index: "test-index" }
- match: { docs.1.doc._source.foo: "rab" }
- match: { docs.1.doc.executed_pipelines: [] }

---
"Test pipeline in query param":

- skip:
features: headers

- do:
headers:
Content-Type: application/json
ingest.put_pipeline:
id: "my-pipeline"
body: >
{
"processors": [
]
}
- match: { acknowledged: true }

- do:
headers:
Content-Type: application/json
simulate.ingest:
pipeline: "my-pipeline"
body: >
{
"docs": [
{
"_index": "index-1",
"_id": "id",
"_source": {
"foo": "bar"
}
},
{
"_index": "index-2",
"_id": "id",
"_source": {
"foo": "rab"
}
}
]
}
- length: { docs: 2 }
- match: { docs.0.doc._index: "index-1" }
- match: { docs.0.doc._source.foo: "bar" }
- match: { docs.0.doc.executed_pipelines: ["my-pipeline"] }
- match: { docs.1.doc._index: "index-2" }
- match: { docs.1.doc._source.foo: "rab" }
- match: { docs.1.doc.executed_pipelines: ["my-pipeline"] }

0 comments on commit 83f5efe

Please sign in to comment.