mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-30 18:33:26 -04:00
* Adding new `require_alias` option to indexing requests (#58917) This commit adds the `require_alias` flag to requests that create new documents. This flag, when `true` prevents the request from automatically creating an index. Instead, the destination of the request MUST be an alias. When the flag is not set, or `false`, the behavior defaults to the `action.auto_create_index` settings. This is useful when an alias is required instead of a concrete index. closes https://github.com/elastic/elasticsearch/issues/55267
This commit is contained in:
parent
65f6fb8e94
commit
b7f30fc929
30 changed files with 447 additions and 36 deletions
|
@ -87,6 +87,10 @@
|
|||
"pipeline":{
|
||||
"type":"string",
|
||||
"description":"The pipeline id to preprocess incoming documents with"
|
||||
},
|
||||
"require_alias": {
|
||||
"type": "boolean",
|
||||
"description": "Sets require_alias for all incoming documents. Defaults to unset (false)"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -139,6 +139,10 @@
|
|||
"pipeline":{
|
||||
"type":"string",
|
||||
"description":"The pipeline id to preprocess incoming documents with"
|
||||
},
|
||||
"require_alias": {
|
||||
"type": "boolean",
|
||||
"description": "When true, requires destination to be an alias. Default is false"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -99,6 +99,10 @@
|
|||
"if_primary_term":{
|
||||
"type":"number",
|
||||
"description":"only perform the update operation if the last operation that has changed the document has the specified primary term"
|
||||
},
|
||||
"require_alias": {
|
||||
"type": "boolean",
|
||||
"description": "When true, requires destination is an alias. Default is false"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -122,3 +122,86 @@
|
|||
{"index": {"_index": "test_index", "_id": "test_id"}}
|
||||
{"f1": "v1", "f2": 42}
|
||||
{}
|
||||
|
||||
---
|
||||
"When setting require_alias flag per request":
|
||||
- skip:
|
||||
version: " - 7.9.99"
|
||||
reason: "require_alias flag was added in version 7.10"
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: backing_index
|
||||
body:
|
||||
mappings: {}
|
||||
aliases:
|
||||
test_require_alias: {}
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
body:
|
||||
- index:
|
||||
_index: new_index_not_created
|
||||
require_alias: true
|
||||
- f: 1
|
||||
- index:
|
||||
_index: new_index_created
|
||||
- f: 2
|
||||
- index:
|
||||
_index: test_require_alias
|
||||
require_alias: true
|
||||
- f: 3
|
||||
- create:
|
||||
_index: test_require_alias
|
||||
- f: 4
|
||||
- match: { errors: true }
|
||||
- match: { items.0.index.status: 404 }
|
||||
- match: { items.0.index.error.type: index_not_found_exception }
|
||||
- match: { items.0.index.error.reason: "no such index [new_index_not_created] and [require_alias] request flag is [true] and [new_index_not_created] is not an alias" }
|
||||
- match: { items.1.index.result: created }
|
||||
- match: { items.2.index.result: created }
|
||||
- match: { items.3.create.result: created }
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get:
|
||||
index: new_index_not_created
|
||||
---
|
||||
"When setting require_alias flag":
|
||||
- skip:
|
||||
version: " - 7.9.99"
|
||||
reason: "require_alias flag was added in version 7.10"
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: backing_index
|
||||
body:
|
||||
mappings: {}
|
||||
aliases:
|
||||
test_require_alias: {}
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
require_alias: true
|
||||
body:
|
||||
- index:
|
||||
_index: new_index_not_created
|
||||
- f: 1
|
||||
- index:
|
||||
_index: new_index_created
|
||||
require_alias: false
|
||||
- f: 2
|
||||
- index:
|
||||
_index: test_require_alias
|
||||
- f: 3
|
||||
- match: { errors: true }
|
||||
- match: { items.0.index.status: 404 }
|
||||
- match: { items.0.index.error.type: index_not_found_exception }
|
||||
- match: { items.0.index.error.reason: "no such index [new_index_not_created] and [require_alias] request flag is [true] and [new_index_not_created] is not an alias" }
|
||||
- match: { items.1.index.result: created }
|
||||
- match: { items.2.index.result: created }
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get:
|
||||
index: new_index_not_created
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
"Set require_alias flag":
|
||||
- skip:
|
||||
version: " - 7.9.99"
|
||||
reason: "require_alias flag added in 7.10"
|
||||
- do:
|
||||
catch: missing
|
||||
index:
|
||||
index: test_require_alias
|
||||
require_alias: true
|
||||
body: { foo: bar }
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get:
|
||||
index: test_require_alias
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: backing_index
|
||||
body:
|
||||
mappings: {}
|
||||
aliases:
|
||||
test_require_alias: {}
|
||||
|
||||
- do:
|
||||
index:
|
||||
index: test_require_alias
|
||||
require_alias: true
|
||||
body: { foo: bar }
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
"Set require_alias flag":
|
||||
- skip:
|
||||
version: " - 7.9.99"
|
||||
reason: "require_alias flag added in 7.10"
|
||||
- do:
|
||||
catch: missing
|
||||
update:
|
||||
index: test_require_alias
|
||||
id: 1
|
||||
require_alias: true
|
||||
body:
|
||||
doc: { foo: bar, count: 1 }
|
||||
doc_as_upsert: true
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get:
|
||||
index: test_require_alias
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: backing_index
|
||||
body:
|
||||
mappings: {}
|
||||
aliases:
|
||||
test_require_alias: {}
|
||||
|
||||
- do:
|
||||
update:
|
||||
index: test_require_alias
|
||||
id: 1
|
||||
require_alias: true
|
||||
body:
|
||||
doc: { foo: bar, count: 1 }
|
||||
doc_as_upsert: true
|
Loading…
Add table
Add a link
Reference in a new issue