Consistent REST API changes for GETting data
* Made GET mappings consistent, supporting * /{index}/_mappings/{type} * /{index}/_mapping/{type} * /_mapping/{type} * Added "mappings" in the JSON response to align it with other responses * Made GET warmers consistent, support /{index}/_warmers/{type} and /_warmer, /_warner/{name} as well as wildcards and _all notation * Made GET aliases consistent, support /{index}/_aliases/{name} and /_alias, /_aliases/{name} as well as wildcards and _all notation * Made GET settings consistent, added /{index}/_setting/{name}, /_settings/{name} as well as supportings wildcards in settings name * Returning empty JSON instead of a 404, if a specific warmer/ setting/alias/type is missing * Added a ton of spec tests for all of the above * Added a couple of more integration tests for several features Relates #4071
This commit is contained in:
parent
b35ca1aa75
commit
349a8be4fd
|
@ -39,12 +39,12 @@ curl -XGET 'http://localhost:9200/my-index/_settings?prefix=index.'
|
|||
|
||||
curl -XGET 'http://localhost:9200/_all/_settings?prefix=index.routing.allocation.'
|
||||
|
||||
curl -XGET 'http://localhost:9200/2013-*/_settings?prefix=index.merge.'
|
||||
curl -XGET 'http://localhost:9200/2013-*/_settings?name=index.merge.*'
|
||||
|
||||
curl -XGET 'http://localhost:9200/2013-*/index.merge./_settings'
|
||||
curl -XGET 'http://localhost:9200/2013-*/_settings/index.merge.*'
|
||||
--------------------------------------------------
|
||||
|
||||
The first example returns all index settings the start with `index.` in the index `my-index`,
|
||||
the second example gets all index settings that start with `index.routing.allocation.` for
|
||||
all indices, lastly the third example returns all index settings that start with `index.merge.`
|
||||
in indices that start with `2013-`.
|
||||
in indices that start with `2013-`.
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html",
|
||||
"methods": ["GET"],
|
||||
"url": {
|
||||
"path": "/_alias/{name}",
|
||||
"paths": ["/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"],
|
||||
"path": "/_alias/",
|
||||
"paths": [ "/_alias", "/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"],
|
||||
"parts": {
|
||||
"index": {
|
||||
"type" : "list",
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
"methods": ["GET"],
|
||||
"url": {
|
||||
"path": "/_aliases",
|
||||
"paths": ["/_aliases", "/{index}/_aliases"],
|
||||
"paths": ["/_aliases", "/{index}/_aliases", "/{index}/_aliases/{name}", "/_aliases/{name}" ],
|
||||
"parts": {
|
||||
"index": {
|
||||
"type" : "list",
|
||||
"description" : "A comma-separated list of index names to filter aliases"
|
||||
},
|
||||
"name": {
|
||||
"type" : "list",
|
||||
"description" : "A comma-separated list of alias names to filter"
|
||||
}
|
||||
},
|
||||
"params": {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"methods": ["GET"],
|
||||
"url": {
|
||||
"path": "/_mapping",
|
||||
"paths": ["/_mapping", "/{index}/_mapping", "/{index}/{type}/_mapping"],
|
||||
"paths": ["/_mapping", "/{index}/_mapping", "/_mapping/{type}", "/{index}/_mapping/{type}"],
|
||||
"parts": {
|
||||
"index": {
|
||||
"type" : "list",
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
"methods": ["GET"],
|
||||
"url": {
|
||||
"path": "/_settings",
|
||||
"paths": ["/_settings", "/{index}/_settings", "/{index}/{prefix}/_settings"],
|
||||
"paths": ["/_settings", "/{index}/_settings", "/{index}/_settings/{name}", "/_settings/{name}"],
|
||||
"parts": {
|
||||
"index": {
|
||||
"type" : "list",
|
||||
"description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices"
|
||||
},
|
||||
"prefix": {
|
||||
"name": {
|
||||
"type" : "string",
|
||||
"description" : "The prefix all settings must have in order to be included"
|
||||
"description" : "The name of the settings that should be included"
|
||||
}
|
||||
},
|
||||
"params": {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html",
|
||||
"methods": ["GET"],
|
||||
"url": {
|
||||
"path": "/{index}/_warmer",
|
||||
"paths": ["/{index}/_warmer", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
|
||||
"path": "/_warmer",
|
||||
"paths": [ "/_warmer", "/{index}/_warmer", "/{index}/_warmer/{name}", "/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
|
||||
"parts": {
|
||||
"index": {
|
||||
"type" : "list",
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
name: testali
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_alias:
|
||||
index: testind
|
||||
name: testali
|
||||
|
||||
- match: { '': {}}
|
||||
|
|
|
@ -49,12 +49,7 @@ setup:
|
|||
name: test_warmer1
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_warmer: { index: _all, name: 'test_warmer1' }
|
||||
|
||||
- do:
|
||||
indices.get_warmer: { index: _all, name: 'test_warmer2' }
|
||||
|
||||
indices.get_warmer: {}
|
||||
|
||||
- match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
|
||||
- match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
@ -68,12 +63,7 @@ setup:
|
|||
name: test_warmer1
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_warmer: { index: _all, name: 'test_warmer1' }
|
||||
|
||||
- do:
|
||||
indices.get_warmer: { index: _all, name: 'test_warmer2' }
|
||||
|
||||
indices.get_warmer: {}
|
||||
|
||||
- match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
|
||||
- match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
@ -146,7 +136,7 @@ setup:
|
|||
---
|
||||
"check delete with index list and _all warmers":
|
||||
- do:
|
||||
indices.delete_warmer:
|
||||
indices.delete_warmer:
|
||||
index: "test_index1,test_index2"
|
||||
name: _all
|
||||
|
||||
|
|
|
@ -0,0 +1,211 @@
|
|||
---
|
||||
setup:
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index_2
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index
|
||||
name: test_alias
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index
|
||||
name: test_blias
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index_2
|
||||
name: test_alias
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index_2
|
||||
name: test_blias
|
||||
|
||||
---
|
||||
"Get all aliases via /_alias":
|
||||
|
||||
- do:
|
||||
indices.get_alias: {}
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_blias: {}}
|
||||
|
||||
|
||||
---
|
||||
"Get all aliases via /{index}/_alias/":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get specific alias via /{index}/_alias/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_alias/_all":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: _all
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_alias/*":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: '*'
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_alias/prefix*":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: 'test_a*'
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_alias/name,name":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: 'test_alias,test_blias'
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /_alias/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /_all/_alias/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: _all
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /*/_alias/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: '*'
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /pref*/_alias/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: '*2'
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_alias
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /name,name/_alias/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index,test_index_2
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
|
||||
---
|
||||
"Non-existent alias on an existing index returns an empty body":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: non-existent
|
||||
|
||||
- match: { '': {}}
|
||||
|
||||
---
|
||||
"Existent and non-existent alias returns just the existing":
|
||||
|
||||
- do:
|
||||
indices.get_alias:
|
||||
index: test_index
|
||||
name: test_alias,non-existent
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.non-existent
|
||||
|
||||
---
|
||||
"Getting alias on an non-existent index should return 404":
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_alias:
|
||||
index: non-existent
|
||||
name: foo
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
---
|
||||
setup:
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index_2
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index
|
||||
name: test_alias
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index
|
||||
name: test_blias
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index_2
|
||||
name: test_alias
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index_2
|
||||
name: test_blias
|
||||
|
||||
---
|
||||
"Get all aliases via /_aliases":
|
||||
|
||||
- do:
|
||||
indices.get_aliases: {}
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_blias: {}}
|
||||
|
||||
|
||||
---
|
||||
"Get all aliases via /{index}/_aliases/":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get specific alias via /{index}/_aliases/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_aliases/_all":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: _all
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_aliases/*":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: '*'
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_aliases/prefix*":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: 'test_a*'
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /{index}/_aliases/name,name":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: 'test_alias,test_blias'
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index.aliases.test_blias: {}}
|
||||
- is_false: test_index_2
|
||||
|
||||
---
|
||||
"Get aliases via /_aliases/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /_all/_aliases/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: _all
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /*/_aliases/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: '*'
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /pref*/_aliases/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: '*2'
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_alias
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
---
|
||||
"Get aliases via /name,name/_aliases/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index,test_index_2
|
||||
name: test_alias
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- match: {test_index_2.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.test_blias
|
||||
- is_false: test_index_2.aliases.test_blias
|
||||
|
||||
|
||||
---
|
||||
"Non-existent alias on an existing index returns matching indcies":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: non-existent
|
||||
|
||||
- match: { test_index.aliases: {}}
|
||||
|
||||
---
|
||||
"Existent and non-existent alias returns just the existing":
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
name: test_alias,non-existent
|
||||
|
||||
- match: {test_index.aliases.test_alias: {}}
|
||||
- is_false: test_index.aliases.non-existent
|
||||
|
||||
---
|
||||
"Getting alias on an non-existent index should return 404":
|
||||
|
||||
- skip:
|
||||
version: 1 - 999
|
||||
reason: not implemented yet
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_aliases:
|
||||
index: non-existent
|
||||
name: foo
|
||||
|
||||
|
||||
|
|
@ -2,31 +2,172 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
index: test_1
|
||||
body:
|
||||
mappings:
|
||||
test_type:
|
||||
properties:
|
||||
text:
|
||||
type: string
|
||||
analyzer: whitespace
|
||||
type_1: {}
|
||||
type_2: {}
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_2
|
||||
body:
|
||||
mappings:
|
||||
type_2: {}
|
||||
type_3: {}
|
||||
|
||||
---
|
||||
"Get index mapping":
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_index
|
||||
"Get /_mapping":
|
||||
|
||||
- match: {test_index.test_type.properties.text.type: string}
|
||||
- match: {test_index.test_type.properties.text.analyzer: whitespace}
|
||||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: { test_1.mappings.type_1.properties: {}}
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- match: { test_2.mappings.type_3.properties: {}}
|
||||
|
||||
---
|
||||
"Get type mapping":
|
||||
"Get /{index}/_mapping":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_index
|
||||
type: test_type
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1
|
||||
|
||||
- match: {test_index.test_type.properties.text.type: string}
|
||||
- match: {test_index.test_type.properties.text.analyzer: whitespace}
|
||||
- match: { test_1.mappings.type_1.properties: {}}
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- is_false: test_2
|
||||
|
||||
|
||||
---
|
||||
"Get /{index}/_mapping/_all":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1
|
||||
type: _all
|
||||
|
||||
- match: { test_1.mappings.type_1.properties: {}}
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_mapping/*":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1
|
||||
type: '*'
|
||||
|
||||
- match: { test_1.mappings.type_1.properties: {}}
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1
|
||||
type: type_1
|
||||
|
||||
- match: { test_1.mappings.type_1.properties: {}}
|
||||
- is_false: test_1.mappings.type_2
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_mapping/{type,type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1
|
||||
type: type_1,type_2
|
||||
|
||||
- match: { test_1.mappings.type_1.properties: {}}
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_mapping/{type*}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1
|
||||
type: '*2'
|
||||
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- is_false: test_1.mappings.type_1
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
type: type_2
|
||||
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- is_false: test_1.mappings.type_1
|
||||
- is_false: test_2.mappings.type_3
|
||||
|
||||
---
|
||||
"Get /_all/_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: _all
|
||||
type: type_2
|
||||
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- is_false: test_1.mappings.type_1
|
||||
- is_false: test_2.mappings.type_3
|
||||
|
||||
---
|
||||
"Get /*/_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: '*'
|
||||
type: type_2
|
||||
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- is_false: test_1.mappings.type_1
|
||||
- is_false: test_2.mappings.type_3
|
||||
|
||||
---
|
||||
"Get /{index}/_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_2
|
||||
type: type_2
|
||||
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- is_false: test_1
|
||||
- is_false: test_2.mappings.type_3
|
||||
|
||||
---
|
||||
"Get /index,index/_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_1,test_2
|
||||
type: type_2
|
||||
|
||||
- match: { test_1.mappings.type_2.properties: {}}
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- is_false: test_2.mappings.type_3
|
||||
|
||||
---
|
||||
"Get /index*/_mapping/{type}":
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: '*2'
|
||||
type: type_2
|
||||
|
||||
- match: { test_2.mappings.type_2.properties: {}}
|
||||
- is_false: test_1
|
||||
- is_false: test_2.mappings.type_3
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
"Raise 404 when type doesn't exist":
|
||||
"Return empty response when type doesn't exist":
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
@ -12,8 +12,8 @@
|
|||
analyzer: whitespace
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_mapping:
|
||||
index: test_index
|
||||
type: not_test_type
|
||||
|
||||
|
||||
- match: { '': {}}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
"Getting mapping for aliases should return the real index as key":
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
body:
|
||||
mappings:
|
||||
test_type:
|
||||
properties:
|
||||
text:
|
||||
type: string
|
||||
analyzer: whitespace
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index
|
||||
name: test_alias
|
||||
|
||||
- do:
|
||||
indices.get_mapping:
|
||||
index: test_alias
|
||||
|
||||
- match: {test_index.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
|
@ -1,32 +1,167 @@
|
|||
---
|
||||
"Test get indices settings":
|
||||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: test-index
|
||||
body:
|
||||
settings:
|
||||
index:
|
||||
refresh_interval: -1
|
||||
number_of_shards: 2
|
||||
number_of_replicas: 3
|
||||
|
||||
indices.create:
|
||||
index: test_1
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test-index
|
||||
indices.create:
|
||||
index: test_2
|
||||
|
||||
- match:
|
||||
test-index.settings.index.number_of_replicas: "3"
|
||||
- match:
|
||||
test-index.settings.index.number_of_shards: "2"
|
||||
- match:
|
||||
test-index.settings.index.refresh_interval: "-1"
|
||||
---
|
||||
"Get /_settings":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
- do:
|
||||
indices.get_settings: {}
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_1.settings.index.number_of_replicas: "1"}
|
||||
- match: { test_2.settings.index.number_of_shards: "5"}
|
||||
- match: { test_2.settings.index.number_of_replicas: "1"}
|
||||
|
||||
---
|
||||
"Get /{index}/_settings":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_1.settings.index.number_of_replicas: "1"}
|
||||
- is_false: test_2
|
||||
|
||||
|
||||
---
|
||||
"Get /{index}/_settings/_all":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
name: _all
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_1.settings.index.number_of_replicas: "1"}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_settings/*":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
name: '*'
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_1.settings.index.number_of_replicas: "1"}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
name: index.number_of_shards
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_settings/{name,name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
name: index.number_of_shards,index.number_of_replicas
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_1.settings.index.number_of_replicas: "1"}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_settings/{name*}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
name: 'index.number_of_s*'
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
name: index.number_of_shards
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_2.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2.settings.index.number_of_replicas
|
||||
|
||||
---
|
||||
"Get /_all/_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: _all
|
||||
prefix: index.number
|
||||
name: index.number_of_shards
|
||||
|
||||
- match:
|
||||
test-index.settings.index.number_of_replicas: "3"
|
||||
- match:
|
||||
test-index.settings.index.number_of_shards: "2"
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_2.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2.settings.index.number_of_replicas
|
||||
|
||||
|
||||
---
|
||||
"Get /*/_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: '*'
|
||||
name: index.number_of_shards
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_2.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2.settings.index.number_of_replicas
|
||||
|
||||
---
|
||||
"Get /{index}/_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1
|
||||
name: index.number_of_shards
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /index,index/_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test_1,test_2
|
||||
name: index.number_of_shards
|
||||
|
||||
- match: { test_1.settings.index.number_of_shards: "5"}
|
||||
- match: { test_2.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1.settings.index.number_of_replicas
|
||||
- is_false: test_2.settings.index.number_of_replicas
|
||||
|
||||
---
|
||||
"Get /index*/_settings/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: '*2'
|
||||
name: index.number_of_shards
|
||||
|
||||
- match: { test_2.settings.index.number_of_shards: "5"}
|
||||
- is_false: test_1
|
||||
- is_false: test_2.settings.index.number_of_replicas
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
"Getting settings for aliases should return the real index as key":
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test-index
|
||||
body:
|
||||
settings:
|
||||
index:
|
||||
refresh_interval: -1
|
||||
number_of_shards: 2
|
||||
number_of_replicas: 3
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test-index
|
||||
name: test-alias
|
||||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: test-alias
|
||||
|
||||
- match: { test-index.settings.index.number_of_replicas: "3" }
|
||||
- match: { test-index.settings.index.number_of_shards: "2" }
|
||||
- match: { test-index.settings.index.refresh_interval: "-1" }
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
---
|
||||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_1
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_2
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
wait_for_status: yellow
|
||||
- do:
|
||||
indices.put_warmer:
|
||||
index: test_1
|
||||
name: warmer_1
|
||||
body: { query: { match_all: { }}}
|
||||
|
||||
- do:
|
||||
indices.put_warmer:
|
||||
index: test_1
|
||||
name: warmer_2
|
||||
body: { query: { match_all: { }}}
|
||||
|
||||
- do:
|
||||
indices.put_warmer:
|
||||
index: test_2
|
||||
name: warmer_2
|
||||
body: { query: { match_all: { }}}
|
||||
- do:
|
||||
indices.put_warmer:
|
||||
index: test_2
|
||||
name: warmer_3
|
||||
body: { query: { match_all: { }}}
|
||||
|
||||
- do:
|
||||
indices.refresh: {}
|
||||
|
||||
---
|
||||
"Get /_warmer":
|
||||
|
||||
- do:
|
||||
indices.get_warmer: {}
|
||||
|
||||
- match: { test_1.warmers.warmer_1.source.query.match_all: {}}
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- match: { test_2.warmers.warmer_3.source.query.match_all: {}}
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1
|
||||
|
||||
- match: { test_1.warmers.warmer_1.source.query.match_all: {}}
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_2
|
||||
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer/_all":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1
|
||||
name: _all
|
||||
|
||||
- match: { test_1.warmers.warmer_1.source.query.match_all: {}}
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer/*":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1
|
||||
name: '*'
|
||||
|
||||
- match: { test_1.warmers.warmer_1.source.query.match_all: {}}
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1
|
||||
name: warmer_1
|
||||
|
||||
- match: { test_1.warmers.warmer_1.source.query.match_all: {}}
|
||||
- is_false: test_1.warmers.warmer_2
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer/{name,name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1
|
||||
name: warmer_1,warmer_2
|
||||
|
||||
- match: { test_1.warmers.warmer_1.source.query.match_all: {}}
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer/{name*}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1
|
||||
name: '*2'
|
||||
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_1.warmers.warmer_1
|
||||
- is_false: test_2
|
||||
|
||||
---
|
||||
"Get /_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
name: warmer_2
|
||||
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_1.warmers.warmer_1
|
||||
- is_false: test_2.warmers.warmer_3
|
||||
|
||||
---
|
||||
"Get /_all/_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: _all
|
||||
name: warmer_2
|
||||
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_1.warmers.warmer_1
|
||||
- is_false: test_2.warmers.warmer_3
|
||||
|
||||
---
|
||||
"Get /*/_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: '*'
|
||||
name: warmer_2
|
||||
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_1.warmers.warmer_1
|
||||
- is_false: test_2.warmers.warmer_3
|
||||
|
||||
---
|
||||
"Get /{index}/_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_2
|
||||
name: warmer_2
|
||||
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_1
|
||||
- is_false: test_2.warmers.warmer_3
|
||||
|
||||
---
|
||||
"Get /index,index/_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_1,test_2
|
||||
name: warmer_2
|
||||
|
||||
- match: { test_1.warmers.warmer_2.source.query.match_all: {}}
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_2.warmers.warmer_3
|
||||
|
||||
---
|
||||
"Get /index*/_warmer/{name}":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: '*2'
|
||||
name: warmer_2
|
||||
|
||||
- match: { test_2.warmers.warmer_2.source.query.match_all: {}}
|
||||
- is_false: test_1
|
||||
- is_false: test_2.warmers.warmer_3
|
||||
|
||||
---
|
||||
"Empty response when no matching warmer":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: '*'
|
||||
name: non_existent
|
||||
|
||||
- match: { '': {}}
|
||||
|
||||
---
|
||||
"Throw 404 on missing index":
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_warmer:
|
||||
index: non_existent
|
||||
name: '*'
|
||||
|
||||
|
|
@ -22,10 +22,10 @@
|
|||
indices.get_mapping:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.test_type.properties.text1.type: string}
|
||||
- match: {test_index.test_type.properties.text1.analyzer: whitespace}
|
||||
- match: {test_index.test_type.properties.text2.type: string}
|
||||
- match: {test_index.test_type.properties.text2.analyzer: whitespace}
|
||||
- match: {test_index.mappings.test_type.properties.text1.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text1.analyzer: whitespace}
|
||||
- match: {test_index.mappings.test_type.properties.text2.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text2.analyzer: whitespace}
|
||||
|
||||
- do:
|
||||
indices.put_mapping:
|
||||
|
@ -56,7 +56,7 @@
|
|||
indices.get_mapping:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.test_type.properties.text1.type: string}
|
||||
- match: {test_index.test_type.properties.text1.fields.text_raw.index: not_analyzed}
|
||||
- match: {test_index.test_type.properties.text2.type: string}
|
||||
- match: {test_index.test_type.properties.text2.fields.text_raw.index: not_analyzed}
|
||||
- match: {test_index.mappings.test_type.properties.text1.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text1.fields.text_raw.index: not_analyzed}
|
||||
- match: {test_index.mappings.test_type.properties.text2.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text2.fields.text_raw.index: not_analyzed}
|
||||
|
|
|
@ -37,13 +37,13 @@ setup:
|
|||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: {test_index1.test_type.properties.text.type: string}
|
||||
- match: {test_index1.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index1.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {test_index2.test_type.properties.text.type: string}
|
||||
- match: {test_index2.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index2.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {foo: {}}
|
||||
- is_false: foo
|
||||
|
||||
---
|
||||
"put mapping in _all index":
|
||||
|
@ -62,14 +62,14 @@ setup:
|
|||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: {test_index1.test_type.properties.text.type: string}
|
||||
- match: {test_index1.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index1.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {test_index2.test_type.properties.text.type: string}
|
||||
- match: {test_index2.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index2.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {foo.test_type.properties.text.type: string}
|
||||
- match: {foo.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {foo.mappings.test_type.properties.text.type: string}
|
||||
- match: {foo.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
---
|
||||
"put mapping in * index":
|
||||
|
@ -87,14 +87,14 @@ setup:
|
|||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: {test_index1.test_type.properties.text.type: string}
|
||||
- match: {test_index1.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index1.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {test_index2.test_type.properties.text.type: string}
|
||||
- match: {test_index2.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index2.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {foo.test_type.properties.text.type: string}
|
||||
- match: {foo.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {foo.mappings.test_type.properties.text.type: string}
|
||||
- match: {foo.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
---
|
||||
"put mapping in prefix* index":
|
||||
|
@ -112,13 +112,13 @@ setup:
|
|||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: {test_index1.test_type.properties.text.type: string}
|
||||
- match: {test_index1.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index1.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {test_index2.test_type.properties.text.type: string}
|
||||
- match: {test_index2.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index2.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {foo: {}}
|
||||
- is_false: foo
|
||||
|
||||
---
|
||||
"put mapping in list of indices":
|
||||
|
@ -136,13 +136,13 @@ setup:
|
|||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: {test_index1.test_type.properties.text.type: string}
|
||||
- match: {test_index1.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index1.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {test_index2.test_type.properties.text.type: string}
|
||||
- match: {test_index2.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index2.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {foo: {}}
|
||||
- is_false: foo
|
||||
|
||||
---
|
||||
"put mapping with blank index":
|
||||
|
@ -159,14 +159,14 @@ setup:
|
|||
- do:
|
||||
indices.get_mapping: {}
|
||||
|
||||
- match: {test_index1.test_type.properties.text.type: string}
|
||||
- match: {test_index1.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index1.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {test_index2.test_type.properties.text.type: string}
|
||||
- match: {test_index2.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {test_index2.mappings.test_type.properties.text.type: string}
|
||||
- match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
- match: {foo.test_type.properties.text.type: string}
|
||||
- match: {foo.test_type.properties.text.analyzer: whitespace}
|
||||
- match: {foo.mappings.test_type.properties.text.type: string}
|
||||
- match: {foo.mappings.test_type.properties.text.analyzer: whitespace}
|
||||
|
||||
---
|
||||
"put mapping with mising type":
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
---
|
||||
"Basic test for warmers":
|
||||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_idx
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
wait_for_status: yellow
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_warmer:
|
||||
index: test_index
|
||||
name: test_warmer
|
||||
indices.put_warmer:
|
||||
index: test_idx
|
||||
name: test_warmer2
|
||||
body:
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
- do:
|
||||
indices.put_warmer:
|
||||
|
@ -22,6 +28,8 @@
|
|||
query:
|
||||
match_all: {}
|
||||
|
||||
---
|
||||
"Basic test for warmers":
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_index
|
||||
|
@ -35,7 +43,103 @@
|
|||
name: test_warmer
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_warmer:
|
||||
index: test_index
|
||||
name: test_warmer
|
||||
|
||||
- match: { '': {}}
|
||||
|
||||
---
|
||||
"Getting all warmers via /_warmer should work":
|
||||
|
||||
- do:
|
||||
indices.get_warmer: {}
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- match: {test_idx.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
||||
|
||||
---
|
||||
"Getting warmers for several indices should work using *":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: '*'
|
||||
name: '*'
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- match: {test_idx.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
||||
---
|
||||
"Getting warmers for several indices should work using _all":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: _all
|
||||
name: _all
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- match: {test_idx.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
||||
---
|
||||
"Getting all warmers without specifying index should work":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
name: _all
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- match: {test_idx.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
||||
---
|
||||
"Getting warmers for several indices should work using prefix*":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_i*
|
||||
name: test_w*
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- match: {test_idx.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
||||
---
|
||||
"Getting warmers for several indices should work using comma-separated lists":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_index,test_idx
|
||||
name: test_warmer,test_warmer2
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- match: {test_idx.warmers.test_warmer2.source.query.match_all: {}}
|
||||
|
||||
---
|
||||
"Getting a non-existent warmer on an existing index should return an empty body":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_index
|
||||
name: non-existent
|
||||
|
||||
- match: { '': {}}
|
||||
|
||||
---
|
||||
"Getting an existent and non-existent warmer should return the existent and no data about the non-existent warmer":
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_index
|
||||
name: test_warmer,non-existent
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
- is_false: test_index.warmers.non-existent
|
||||
|
||||
---
|
||||
"Getting warmer on an non-existent index should return 404":
|
||||
|
||||
- do:
|
||||
catch: missing
|
||||
indices.get_warmer:
|
||||
index: non-existent
|
||||
name: foo
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
"Getting warmer for aliases should return the real index as key":
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
wait_for_status: yellow
|
||||
|
||||
- do:
|
||||
indices.put_warmer:
|
||||
index: test_index
|
||||
name: test_warmer
|
||||
body:
|
||||
query:
|
||||
match_all: {}
|
||||
|
||||
- do:
|
||||
indices.put_alias:
|
||||
index: test_index
|
||||
name: test_alias
|
||||
|
||||
- do:
|
||||
indices.get_warmer:
|
||||
index: test_alias
|
||||
|
||||
- match: {test_index.warmers.test_warmer.source.query.match_all: {}}
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.action.admin.indices.settings.get;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.ValidateActions;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequest;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -34,7 +35,7 @@ public class GetSettingsRequest extends MasterNodeOperationRequest<GetSettingsRe
|
|||
|
||||
private String[] indices = Strings.EMPTY_ARRAY;
|
||||
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
|
||||
private String prefix;
|
||||
private String[] names = Strings.EMPTY_ARRAY;
|
||||
|
||||
public GetSettingsRequest indices(String... indices) {
|
||||
this.indices = indices;
|
||||
|
@ -54,18 +55,22 @@ public class GetSettingsRequest extends MasterNodeOperationRequest<GetSettingsRe
|
|||
return indicesOptions;
|
||||
}
|
||||
|
||||
public String prefix() {
|
||||
return prefix;
|
||||
public String[] names() {
|
||||
return names;
|
||||
}
|
||||
|
||||
public GetSettingsRequest prefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
public GetSettingsRequest names(String... names) {
|
||||
this.names = names;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (names == null) {
|
||||
validationException = ValidateActions.addValidationError("names may not be null", validationException);
|
||||
}
|
||||
return validationException;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +78,7 @@ public class GetSettingsRequest extends MasterNodeOperationRequest<GetSettingsRe
|
|||
super.readFrom(in);
|
||||
indices = in.readStringArray();
|
||||
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
||||
prefix = in.readOptionalString();
|
||||
names = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,6 +86,6 @@ public class GetSettingsRequest extends MasterNodeOperationRequest<GetSettingsRe
|
|||
super.writeTo(out);
|
||||
out.writeStringArray(indices);
|
||||
indicesOptions.writeIndicesOptions(out);
|
||||
out.writeOptionalString(prefix);
|
||||
out.writeStringArray(names);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ public class GetSettingsRequestBuilder extends MasterNodeOperationRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
public GetSettingsRequestBuilder setPrefix(String prefix) {
|
||||
request.prefix(prefix);
|
||||
public GetSettingsRequestBuilder setNames(String... names) {
|
||||
request.names(names);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,11 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
|
@ -80,10 +82,10 @@ public class TransportGetSettingsAction extends TransportMasterNodeOperationActi
|
|||
}
|
||||
|
||||
Settings settings = settingsFilter.filterSettings(indexMetaData.settings());
|
||||
if (request.prefix() != null) {
|
||||
if (!CollectionUtils.isEmpty(request.names())) {
|
||||
ImmutableSettings.Builder settingsBuilder = ImmutableSettings.builder();
|
||||
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
|
||||
if (entry.getKey().startsWith(request.prefix())) {
|
||||
if (Regex.simpleMatch(request.names(), entry.getKey())) {
|
||||
settingsBuilder.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,12 +376,14 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
return indexMapBuilder.build();
|
||||
}
|
||||
|
||||
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> findWarmers(String[] concreteIndices, final String[] types, final String[] warmers) {
|
||||
assert warmers != null;
|
||||
public ImmutableOpenMap<String, ImmutableList<IndexWarmersMetaData.Entry>> findWarmers(String[] concreteIndices, final String[] types, final String[] uncheckedWarmers) {
|
||||
assert uncheckedWarmers != null;
|
||||
assert concreteIndices != null;
|
||||
if (concreteIndices.length == 0) {
|
||||
return ImmutableOpenMap.of();
|
||||
}
|
||||
// special _all check to behave the same like not specifying anything for the warmers (not for the indices)
|
||||
final String[] warmers = Strings.isAllOrWildcard(uncheckedWarmers) ? Strings.EMPTY_ARRAY : uncheckedWarmers;
|
||||
|
||||
ImmutableOpenMap.Builder<String, ImmutableList<IndexWarmersMetaData.Entry>> mapBuilder = ImmutableOpenMap.builder();
|
||||
Iterable<String> intersection = HppcMaps.intersection(ObjectOpenHashSet.from(concreteIndices), indices.keys());
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
import org.apache.lucene.util.UnicodeUtil;
|
||||
import org.elasticsearch.ElasticsearchIllegalStateException;
|
||||
import org.elasticsearch.common.io.FastStringReader;
|
||||
import org.elasticsearch.common.util.CollectionUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
@ -1565,4 +1566,14 @@ public class Strings {
|
|||
return s.substring(beginIndex, endIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If an array only consists of zero or one element, which is "*" or "_all" return an empty array
|
||||
* which is usually used as everything
|
||||
*/
|
||||
public static boolean isAllOrWildcard(String[] data) {
|
||||
return CollectionUtils.isEmpty(data) ||
|
||||
data.length == 1 && ("_all".equals(data[0]) || "*".equals(data[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -158,4 +158,13 @@ public abstract class RestRequest implements ToXContent.Params {
|
|||
}
|
||||
return Strings.splitStringByCommaToArray(value);
|
||||
}
|
||||
|
||||
public String[] paramAsStringArrayOrEmptyIfAll(String key) {
|
||||
String[] params = paramAsStringArray(key, Strings.EMPTY_ARRAY);
|
||||
if (Strings.isAllOrWildcard(params)) {
|
||||
return Strings.EMPTY_ARRAY;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class RestGetAliasesAction extends BaseRestHandler {
|
|||
@Inject
|
||||
public RestGetAliasesAction(Settings settings, Client client, RestController controller) {
|
||||
super(settings, client);
|
||||
controller.registerHandler(GET, "/_alias/", this);
|
||||
controller.registerHandler(GET, "/_alias/{name}", this);
|
||||
controller.registerHandler(GET, "/{index}/_alias/{name}", this);
|
||||
controller.registerHandler(GET, "/{index}/_alias", this);
|
||||
|
@ -56,7 +57,7 @@ public class RestGetAliasesAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||
String[] aliases = request.paramAsStringArray("name", Strings.EMPTY_ARRAY);
|
||||
final String[] aliases = request.paramAsStringArrayOrEmptyIfAll("name");
|
||||
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
|
||||
final GetAliasesRequest getAliasesRequest = new GetAliasesRequest(aliases);
|
||||
getAliasesRequest.indices(indices);
|
||||
|
@ -68,7 +69,11 @@ public class RestGetAliasesAction extends BaseRestHandler {
|
|||
public void onResponse(GetAliasesResponse response) {
|
||||
try {
|
||||
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
|
||||
if (response.getAliases().isEmpty()) {
|
||||
// empty body, if indices were specified but no aliases were
|
||||
if (indices.length > 0 && response.getAliases().isEmpty()) {
|
||||
channel.sendResponse(new XContentRestResponse(request, OK, RestXContentBuilder.emptyBuilder(request)));
|
||||
return;
|
||||
} else if (response.getAliases().isEmpty()) {
|
||||
String message = String.format(Locale.ROOT, "alias [%s] missing", toNamesString(getAliasesRequest.aliases()));
|
||||
builder.startObject()
|
||||
.field("error", message)
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -37,6 +38,7 @@ import org.elasticsearch.rest.action.support.RestXContentBuilder;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.common.Strings.isAllOrWildcard;
|
||||
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
||||
import static org.elasticsearch.rest.RestStatus.OK;
|
||||
|
||||
|
@ -50,16 +52,19 @@ public class RestGetIndicesAliasesAction extends BaseRestHandler {
|
|||
super(settings, client);
|
||||
controller.registerHandler(GET, "/_aliases", this);
|
||||
controller.registerHandler(GET, "/{index}/_aliases", this);
|
||||
controller.registerHandler(GET, "/{index}/_aliases/{name}", this);
|
||||
controller.registerHandler(GET, "/_aliases/{name}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
|
||||
final String[] aliases = Strings.splitStringByCommaToArray(request.param("name"));
|
||||
|
||||
ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
|
||||
.routingTable(false)
|
||||
.nodes(false)
|
||||
.indices(indices);
|
||||
.routingTable(false)
|
||||
.nodes(false)
|
||||
.indices(indices);
|
||||
|
||||
clusterStateRequest.listenerThreaded(false);
|
||||
|
||||
|
@ -71,20 +76,22 @@ public class RestGetIndicesAliasesAction extends BaseRestHandler {
|
|||
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
|
||||
builder.startObject();
|
||||
|
||||
final boolean isAllAliasesRequested = isAllOrWildcard(aliases);
|
||||
for (IndexMetaData indexMetaData : metaData) {
|
||||
builder.startObject(indexMetaData.index(), XContentBuilder.FieldCaseConversion.NONE);
|
||||
|
||||
builder.startObject("aliases");
|
||||
for (ObjectCursor<AliasMetaData> cursor : indexMetaData.aliases().values()) {
|
||||
AliasMetaData.Builder.toXContent(cursor.value, builder, ToXContent.EMPTY_PARAMS);
|
||||
}
|
||||
builder.endObject();
|
||||
|
||||
for (ObjectCursor<AliasMetaData> cursor : indexMetaData.aliases().values()) {
|
||||
if (isAllAliasesRequested || Regex.simpleMatch(aliases, cursor.value.alias())) {
|
||||
AliasMetaData.Builder.toXContent(cursor.value, builder, ToXContent.EMPTY_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
builder.endObject();
|
||||
|
||||
channel.sendResponse(new XContentRestResponse(request, OK, builder));
|
||||
} catch (Throwable e) {
|
||||
onFailure(e);
|
||||
|
@ -101,4 +108,5 @@ public class RestGetIndicesAliasesAction extends BaseRestHandler {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
import org.elasticsearch.indices.TypeMissingException;
|
||||
|
@ -53,12 +54,15 @@ public class RestGetMappingAction extends BaseRestHandler {
|
|||
controller.registerHandler(GET, "/_mapping", this);
|
||||
controller.registerHandler(GET, "/{index}/_mapping", this);
|
||||
controller.registerHandler(GET, "/{index}/{type}/_mapping", this);
|
||||
controller.registerHandler(GET, "/{index}/_mappings/{type}", this);
|
||||
controller.registerHandler(GET, "/{index}/_mapping/{type}", this);
|
||||
controller.registerHandler(GET, "/_mapping/{type}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
|
||||
final String[] types = Strings.splitStringByCommaToArray(request.param("type"));
|
||||
final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
|
||||
boolean local = request.paramAsBooleanOptional("local", false);
|
||||
GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
|
||||
getMappingsRequest.indices(indices).types(types).local(local);
|
||||
|
@ -74,7 +78,7 @@ public class RestGetMappingAction extends BaseRestHandler {
|
|||
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsByIndex = response.getMappings();
|
||||
if (mappingsByIndex.isEmpty()) {
|
||||
if (indices.length != 0 && types.length != 0) {
|
||||
channel.sendResponse(new XContentThrowableRestResponse(request, new TypeMissingException(new Index(indices[0]), types[0])));
|
||||
channel.sendResponse(new XContentRestResponse(request, OK, RestXContentBuilder.emptyBuilder(request)));
|
||||
} else if (indices.length != 0) {
|
||||
channel.sendResponse(new XContentThrowableRestResponse(request, new IndexMissingException(new Index(indices[0]))));
|
||||
} else if (types.length != 0) {
|
||||
|
@ -87,12 +91,17 @@ public class RestGetMappingAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
for (ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetaData>> indexEntry : mappingsByIndex) {
|
||||
if (indexEntry.value.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
builder.startObject(indexEntry.key, XContentBuilder.FieldCaseConversion.NONE);
|
||||
builder.startObject(Fields.MAPPINGS);
|
||||
for (ObjectObjectCursor<String, MappingMetaData> typeEntry : indexEntry.value) {
|
||||
builder.field(typeEntry.key);
|
||||
builder.map(typeEntry.value.sourceAsMap());
|
||||
}
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
builder.endObject();
|
||||
|
@ -112,4 +121,8 @@ public class RestGetMappingAction extends BaseRestHandler {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
static class Fields {
|
||||
static final XContentBuilderString MAPPINGS = new XContentBuilderString("mappings");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,34 +46,39 @@ public class RestGetSettingsAction extends BaseRestHandler {
|
|||
super(settings, client);
|
||||
controller.registerHandler(GET, "/_settings", this);
|
||||
controller.registerHandler(GET, "/{index}/_settings", this);
|
||||
controller.registerHandler(GET, "/{index}/{prefix}/_settings", this);
|
||||
controller.registerHandler(GET, "/{index}/_settings/{name}", this);
|
||||
controller.registerHandler(GET, "/_settings/{name}", this);
|
||||
controller.registerHandler(GET, "/{index}/_setting/{name}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||
final String[] names = request.paramAsStringArrayOrEmptyIfAll("name");
|
||||
GetSettingsRequest getSettingsRequest = new GetSettingsRequest()
|
||||
.indices(Strings.splitStringByCommaToArray(request.param("index")))
|
||||
.indicesOptions(IndicesOptions.fromRequest(request, IndicesOptions.strict()))
|
||||
.prefix(request.param("prefix"));
|
||||
.names(names);
|
||||
|
||||
client.admin().indices().getSettings(getSettingsRequest, new ActionListener<GetSettingsResponse>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(GetSettingsResponse getSettingsResponse) {
|
||||
try {
|
||||
boolean foundAny = false;
|
||||
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
|
||||
builder.startObject();
|
||||
for (ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) {
|
||||
// no settings, jump over it to shorten the response data
|
||||
if (cursor.value.getAsMap().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
builder.startObject(cursor.key, XContentBuilder.FieldCaseConversion.NONE);
|
||||
foundAny = true;
|
||||
builder.startObject(Fields.SETTINGS);
|
||||
cursor.value.toXContent(builder, request);
|
||||
builder.endObject();
|
||||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
channel.sendResponse(new XContentRestResponse(request, foundAny ? OK : NOT_FOUND, builder));
|
||||
channel.sendResponse(new XContentRestResponse(request, OK, builder));
|
||||
} catch (IOException e) {
|
||||
onFailure(e);
|
||||
}
|
||||
|
|
|
@ -48,9 +48,11 @@ public class RestGetWarmerAction extends BaseRestHandler {
|
|||
@Inject
|
||||
public RestGetWarmerAction(Settings settings, Client client, RestController controller) {
|
||||
super(settings, client);
|
||||
|
||||
controller.registerHandler(GET, "/_warmer", this);
|
||||
controller.registerHandler(GET, "/_warmer/{name}", this);
|
||||
controller.registerHandler(GET, "/{index}/_warmer", this);
|
||||
controller.registerHandler(GET, "/{index}/_warmer/{name}", this);
|
||||
controller.registerHandler(GET, "/{index}/_warmers/{name}", this);
|
||||
controller.registerHandler(GET, "/{index}/{type}/_warmer/{name}", this);
|
||||
}
|
||||
|
||||
|
@ -70,7 +72,7 @@ public class RestGetWarmerAction extends BaseRestHandler {
|
|||
public void onResponse(GetWarmersResponse response) {
|
||||
try {
|
||||
if (indices.length > 0 && response.warmers().isEmpty()) {
|
||||
channel.sendResponse(new XContentThrowableRestResponse(request, new IndexMissingException(new Index(indices[0]))));
|
||||
channel.sendResponse(new XContentRestResponse(request, OK, RestXContentBuilder.emptyBuilder(request)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ public class RestXContentBuilder {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static XContentBuilder emptyBuilder(RestRequest request) throws IOException {
|
||||
return restContentBuilder(request, request.hasContent() ? request.content() : null).startObject().endObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly writes the source to the output builder
|
||||
*/
|
||||
|
|
|
@ -231,6 +231,36 @@ public class SimpleIndicesWarmerTests extends ElasticsearchIntegrationTest {
|
|||
assertThat(getWarmerRuns(), equalTo(warmerRunsAfterDisabling));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gettingAllWarmersUsingAllAndWildcardsShouldWork() throws Exception {
|
||||
client().admin().indices().prepareCreate("test")
|
||||
.setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1, "index.number_of_replicas", 0))
|
||||
.execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
PutWarmerResponse putWarmerResponse = client().admin().indices().preparePutWarmer("custom_warmer")
|
||||
.setSearchRequest(client().prepareSearch("test").setTypes("test").setQuery(QueryBuilders.matchAllQuery()))
|
||||
.execute().actionGet();
|
||||
assertThat(putWarmerResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
PutWarmerResponse anotherPutWarmerResponse = client().admin().indices().preparePutWarmer("second_custom_warmer")
|
||||
.setSearchRequest(client().prepareSearch("test").setTypes("test").setQuery(QueryBuilders.matchAllQuery()))
|
||||
.execute().actionGet();
|
||||
assertThat(anotherPutWarmerResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
GetWarmersResponse getWarmersResponse = client().admin().indices().prepareGetWarmers("*").addWarmers("*").get();
|
||||
assertThat(getWarmersResponse.warmers().size(), is(1));
|
||||
|
||||
getWarmersResponse = client().admin().indices().prepareGetWarmers("_all").addWarmers("_all").get();
|
||||
assertThat(getWarmersResponse.warmers().size(), is(1));
|
||||
|
||||
getWarmersResponse = client().admin().indices().prepareGetWarmers("t*").addWarmers("c*").get();
|
||||
assertThat(getWarmersResponse.warmers().size(), is(1));
|
||||
|
||||
getWarmersResponse = client().admin().indices().prepareGetWarmers("test").addWarmers("custom_warmer", "second_custom_warmer").get();
|
||||
assertThat(getWarmersResponse.warmers().size(), is(1));
|
||||
}
|
||||
|
||||
private long getWarmerRuns() {
|
||||
IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats("test").clear().setWarmer(true).execute().actionGet();
|
||||
return indicesStatsResponse.getIndex("test").getPrimaries().warmer.total();
|
||||
|
|
Loading…
Reference in New Issue