New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added GET Index API #7234
Added GET Index API #7234
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[[indices-get-index]] | ||
== Get Index | ||
|
||
The get index API allows to retrieve information about one or more indexes. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
$ curl -XGET 'http://localhost:9200/twitter/' | ||
-------------------------------------------------- | ||
|
||
The above example gets the information for an index called `twitter`. Specifying an index, | ||
alias or wildcard expression is required. | ||
|
||
The get index API can also be applied to more than one index, or on | ||
all indices by using `_all` or `*` as index. | ||
|
||
[float] | ||
=== Filtering index information | ||
|
||
The information returned by the get API can be filtered to include only specific features | ||
by specifying a comma delimited list of features in the URL: | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
$ curl -XGET 'http://localhost:9200/twitter/_settings,_mappings' | ||
-------------------------------------------------- | ||
|
||
The above command will only return the settings and mappings for the index called `twitter`. | ||
|
||
The available features are `_settings`, `_mappings`, `_warmers` and `_aliases`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"indices.get":{ | ||
"documentation":"http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/indices-get.html", | ||
"methods":[ "GET" ], | ||
"url":{ | ||
"path":"/{index}", | ||
"paths":[ "/{index}", "/{index}/{feature}" ], | ||
"parts":{ | ||
"index":{ | ||
"type":"list", | ||
"description":"A comma-separated list of index names" | ||
}, | ||
"feature":{ | ||
"type":"list", | ||
"description":"A comma-separated list of features" | ||
} | ||
}, | ||
"params":{ | ||
"local":{ | ||
"type":"boolean", | ||
"description":"Return local information, do not retrieve the state from master node (default: false)" | ||
}, | ||
"ignore_unavailable":{ | ||
"type":"boolean", | ||
"description":"Ignore unavailable indexes (default: false)" | ||
}, | ||
"allow_no_indices":{ | ||
"type":"boolean", | ||
"description":"Ignore if a wildcard expression resolves to no concrete indices (default: false)" | ||
}, | ||
"expand_wildcards":{ | ||
"type":"list", | ||
"description":"Whether wildcard expressions should get expanded to open or closed indices (default: open)" | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
--- | ||
setup: | ||
|
||
- do: | ||
indices.create: | ||
index: test_index | ||
body: | ||
aliases: | ||
test_alias: {} | ||
test_blias: {} | ||
mappings: | ||
type_1: {} | ||
warmers: | ||
test_warmer: | ||
source: | ||
query: | ||
match_all: {} | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 1 | ||
|
||
- do: | ||
indices.create: | ||
index: test_index_2 | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
number_of_replicas: 2 | ||
aliases: | ||
test_alias: {} | ||
test_blias: {} | ||
|
||
- do: | ||
indices.create: | ||
index: test_index_3 | ||
body: | ||
aliases: | ||
test_alias: {} | ||
test_blias: {} | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: yellow | ||
|
||
- do: | ||
indices.close: | ||
index: test_index_3 | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: yellow | ||
|
||
--- | ||
"Get index infos": | ||
|
||
- do: | ||
indices.get: | ||
index: test_index | ||
|
||
- is_true: test_index.aliases | ||
- is_true: test_index.settings | ||
- is_true: test_index.warmers | ||
- is_true: test_index.mappings | ||
|
||
--- | ||
"Get index infos for mappings only": | ||
|
||
- do: | ||
indices.get: | ||
index: test_index | ||
feature: _mapping | ||
|
||
- is_true: test_index.mappings | ||
- is_false: test_index.aliases | ||
- is_false: test_index.settings | ||
- is_false: test_index.warmers | ||
|
||
--- | ||
"Get index infos for mappings and warmers only": | ||
|
||
- do: | ||
indices.get: | ||
index: test_index | ||
feature: _mapping,_warmer | ||
|
||
- is_true: test_index.mappings | ||
- is_true: test_index.warmers | ||
- is_false: test_index.aliases | ||
- is_false: test_index.settings | ||
|
||
--- | ||
"Get index infos should work on aliases": | ||
|
||
- do: | ||
indices.get: | ||
index: test_blias | ||
feature: _mapping,_warmer | ||
|
||
- is_true: test_index.mappings | ||
- is_true: test_index.warmers | ||
- is_false: test_index.aliases | ||
- is_false: test_index.settings | ||
|
||
--- | ||
"Get index infos should work for wildcards": | ||
|
||
- do: | ||
indices.get: | ||
index: test_* | ||
feature: _mapping,_settings | ||
|
||
- is_true: test_index.mappings | ||
- is_true: test_index.settings | ||
- is_true: test_index_2.settings | ||
- is_false: test_index.aliases | ||
- is_false: test_index.warmers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add some negative tests, like what happens if the index is not there etc.? Also does the api support the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added tests for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks! |
||
|
||
--- | ||
"Missing index should throw an Error": | ||
|
||
- do: | ||
catch: missing | ||
indices.get: | ||
index: test_not_found | ||
|
||
--- | ||
"Missing index should return empty object if ignore_unavailable": | ||
|
||
- do: | ||
indices.get: | ||
index: test_not_found | ||
ignore_unavailable: true | ||
|
||
- match: { $body: "{}" } | ||
|
||
--- | ||
"Should return empty object if allow_no_indices": | ||
|
||
- do: | ||
indices.get: | ||
index: test_not* | ||
|
||
- match: { $body: "{}" } | ||
|
||
--- | ||
"Should throw error if allow_no_indices=false": | ||
|
||
- do: | ||
catch: missing | ||
indices.get: | ||
index: test_not* | ||
allow_no_indices: false | ||
|
||
--- | ||
"Should return test_index_2 if expand_wildcards=open": | ||
|
||
- do: | ||
indices.get: | ||
index: test_index_* | ||
expand_wildcards: open | ||
|
||
- is_true: test_index_2.settings | ||
- is_false: test_index_3.settings | ||
|
||
--- | ||
"Should return test_index_3 if expand_wildcards=closed": | ||
|
||
- skip: | ||
version: "0 - 2.0.0" | ||
reason: Requires fix for issue 7258 | ||
|
||
- do: | ||
indices.get: | ||
index: test_index_* | ||
feature: _settings | ||
expand_wildcards: closed | ||
|
||
- is_false: test_index_2.settings | ||
- is_true: test_index_3.settings | ||
|
||
--- | ||
"Should return test_index_2 and test_index_3 if expand_wildcards=open,closed": | ||
|
||
- do: | ||
indices.get: | ||
index: test_index_* | ||
feature: _settings | ||
expand_wildcards: open,closed | ||
|
||
- is_true: test_index_2.settings | ||
- is_true: test_index_3.settings | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these breaking changes properly documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added notes to the relevant pages and to the
breaking changes in 1.4
page. This required me to rebase on master as the breaking changes page is new