added custom rest specs for index and bulk that support the ingest param and added rest tests that verify that the ingest param is working
This commit is contained in:
parent
6e428af458
commit
8df9fc82d9
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"ingest.bulk": {
|
||||||
|
"documentation": "Copied from bulk in core to add the pipeline parameter to rest spec",
|
||||||
|
"methods": ["POST", "PUT"],
|
||||||
|
"url": {
|
||||||
|
"path": "/_bulk",
|
||||||
|
"paths": ["/_bulk", "/{index}/_bulk", "/{index}/{type}/_bulk"],
|
||||||
|
"parts": {
|
||||||
|
"index": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Default index for items which don't provide one"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Default document type for items which don't provide one"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"consistency": {
|
||||||
|
"type" : "enum",
|
||||||
|
"options" : ["one", "quorum", "all"],
|
||||||
|
"description" : "Explicit write consistency setting for the operation"
|
||||||
|
},
|
||||||
|
"refresh": {
|
||||||
|
"type" : "boolean",
|
||||||
|
"description" : "Refresh the index after performing the operation"
|
||||||
|
},
|
||||||
|
"routing": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Specific routing value"
|
||||||
|
},
|
||||||
|
"timeout": {
|
||||||
|
"type" : "time",
|
||||||
|
"description" : "Explicit operation timeout"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Default document type for items which don't provide one"
|
||||||
|
},
|
||||||
|
"fields": {
|
||||||
|
"type": "list",
|
||||||
|
"description" : "Default comma-separated list of fields to return in the response for updates"
|
||||||
|
},
|
||||||
|
"ingest" : {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "The pipeline id to preprocess incoming documents with"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"description" : "The operation definition and data (action-data pairs), separated by newlines",
|
||||||
|
"required" : true,
|
||||||
|
"serialize" : "bulk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
{
|
||||||
|
"ingest.index": {
|
||||||
|
"documentation": "Copied from index in core to add support for the pipeline parameter to rest spec",
|
||||||
|
"methods": ["POST", "PUT"],
|
||||||
|
"url": {
|
||||||
|
"path": "/{index}/{type}",
|
||||||
|
"paths": ["/{index}/{type}", "/{index}/{type}/{id}"],
|
||||||
|
"parts": {
|
||||||
|
"id": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Document ID"
|
||||||
|
},
|
||||||
|
"index": {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : true,
|
||||||
|
"description" : "The name of the index"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : true,
|
||||||
|
"description" : "The type of the document"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"params": {
|
||||||
|
"consistency": {
|
||||||
|
"type" : "enum",
|
||||||
|
"options" : ["one", "quorum", "all"],
|
||||||
|
"description" : "Explicit write consistency setting for the operation"
|
||||||
|
},
|
||||||
|
"op_type": {
|
||||||
|
"type" : "enum",
|
||||||
|
"options" : ["index", "create"],
|
||||||
|
"default" : "index",
|
||||||
|
"description" : "Explicit operation type"
|
||||||
|
},
|
||||||
|
"parent": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "ID of the parent document"
|
||||||
|
},
|
||||||
|
"refresh": {
|
||||||
|
"type" : "boolean",
|
||||||
|
"description" : "Refresh the index after performing the operation"
|
||||||
|
},
|
||||||
|
"routing": {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "Specific routing value"
|
||||||
|
},
|
||||||
|
"timeout": {
|
||||||
|
"type" : "time",
|
||||||
|
"description" : "Explicit operation timeout"
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type" : "time",
|
||||||
|
"description" : "Explicit timestamp for the document"
|
||||||
|
},
|
||||||
|
"ttl": {
|
||||||
|
"type" : "duration",
|
||||||
|
"description" : "Expiration time for the document"
|
||||||
|
},
|
||||||
|
"version" : {
|
||||||
|
"type" : "number",
|
||||||
|
"description" : "Explicit version number for concurrency control"
|
||||||
|
},
|
||||||
|
"version_type": {
|
||||||
|
"type" : "enum",
|
||||||
|
"options" : ["internal", "external", "external_gte", "force"],
|
||||||
|
"description" : "Specific version type"
|
||||||
|
},
|
||||||
|
"ingest" : {
|
||||||
|
"type" : "string",
|
||||||
|
"description" : "The pipeline id to preprocess incoming documents with"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"description" : "The document",
|
||||||
|
"required" : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
{
|
{
|
||||||
"simple" : {
|
"simple" : {
|
||||||
"path" : "field1",
|
"path" : "field1",
|
||||||
"value" : "_value",
|
"expected_value" : "_value",
|
||||||
"add_field" : "field2",
|
"add_field" : "field2",
|
||||||
"add_field_value" : "_value"
|
"add_field_value" : "_value"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
---
|
||||||
|
"Test simple processor":
|
||||||
|
- do:
|
||||||
|
cluster.health:
|
||||||
|
wait_for_status: green
|
||||||
|
|
||||||
|
- do:
|
||||||
|
ingest.put_pipeline:
|
||||||
|
id: "my_pipeline"
|
||||||
|
body: >
|
||||||
|
{
|
||||||
|
"description": "_description",
|
||||||
|
"processors": [
|
||||||
|
{
|
||||||
|
"simple" : {
|
||||||
|
"path" : "field1",
|
||||||
|
"expected_value" : "_value",
|
||||||
|
"add_field" : "field2",
|
||||||
|
"add_field_value" : "_value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
- match: { _id: "my_pipeline" }
|
||||||
|
|
||||||
|
# Simulate a Thread.sleep(), because pipeline are updated in the background
|
||||||
|
- do:
|
||||||
|
catch: request_timeout
|
||||||
|
cluster.health:
|
||||||
|
wait_for_nodes: 99
|
||||||
|
timeout: 2s
|
||||||
|
- match: { "timed_out": true }
|
||||||
|
|
||||||
|
- do:
|
||||||
|
ingest.index:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
ingest: "my_pipeline"
|
||||||
|
body: {field1: "_value"}
|
||||||
|
|
||||||
|
- do:
|
||||||
|
get:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 1
|
||||||
|
- match: { _source.field1: "_value" }
|
||||||
|
- match: { _source.field2: "_value" }
|
||||||
|
|
||||||
|
- do:
|
||||||
|
ingest.bulk:
|
||||||
|
ingest: "my_pipeline"
|
||||||
|
body:
|
||||||
|
- '{ "index": { "_index": "test", "_type": "test", "_id": "2" } }'
|
||||||
|
- '{ "field1": "_value" }'
|
||||||
|
|
||||||
|
- do:
|
||||||
|
get:
|
||||||
|
index: test
|
||||||
|
type: test
|
||||||
|
id: 2
|
||||||
|
- match: { _source.field1: "_value" }
|
||||||
|
- match: { _source.field2: "_value" }
|
Loading…
Reference in New Issue