diff options
Diffstat (limited to 'rest-api-spec')
274 files changed, 13943 insertions, 0 deletions
diff --git a/rest-api-spec/.gitignore b/rest-api-spec/.gitignore new file mode 100644 index 0000000..ab11000 --- /dev/null +++ b/rest-api-spec/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +Gemfile.lock +*.swp +tmp/ diff --git a/rest-api-spec/LICENSE.txt b/rest-api-spec/LICENSE.txt new file mode 100644 index 0000000..7b9fbe3 --- /dev/null +++ b/rest-api-spec/LICENSE.txt @@ -0,0 +1,13 @@ +Copyright (c) 2013 Elasticsearch + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/rest-api-spec/README.markdown b/rest-api-spec/README.markdown new file mode 100644 index 0000000..012b3e9 --- /dev/null +++ b/rest-api-spec/README.markdown @@ -0,0 +1,65 @@ +# Elasticsearch REST API JSON specification + +This repository contains a collection of JSON files which describe the [Elasticsearch](http://elasticsearch.org) HTTP API. + +Their purpose is to formalize and standardize the API, to facilitate development of libraries and integrations. + +Example for the ["Create Index"](http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index/) API: + +```json +{ + "indices.create": { + "documentation": "http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index/", + "methods": ["PUT", "POST"], + "url": { + "path": "/{index}", + "paths": ["/{index}"], + "parts": { + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": { + "description" : "The configuration for the index (`settings` and `mappings`)" + } + } +} +``` + +The specification contains: + +* The _name_ of the API (`indices.create`), which usually corresponds to the client calls +* Link to the documentation at <http://elasticsearch.org> +* List of HTTP methods for the endpoint +* URL specification: path, parts, parameters +* Whether body is allowed for the endpoint or not and its description + +The `methods` and `url.paths` elements list all possible HTTP methods and URLs for the endpoint; +it is the responsibility of the developer to use this information for a sensible API on the target platform. + +# Utilities + +The repository contains some utilities in the `utils` directory: + +* The `thor api:generate:spec` will generate the basic JSON specification from Java source code +* The `thor api:generate:code` generates Ruby source code and tests from the specs, and can be extended + to generate assets in another programming language + +Run `bundle install` and then `thor list` in the _utils_ folder. + +The full command to generate the api spec is: + + thor api:spec:generate --output=myfolder --elasticsearch=/path/to/es + +## License + +This software is licensed under the Apache 2 license. diff --git a/rest-api-spec/api/bulk.json b/rest-api-spec/api/bulk.json new file mode 100644 index 0000000..aefbee7 --- /dev/null +++ b/rest-api-spec/api/bulk.json @@ -0,0 +1,58 @@ +{ + "bulk": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-bulk.html", + "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" + }, + "replication": { + "type" : "enum", + "options" : ["sync","async"], + "default" : "sync", + "description" : "Explicitely set the replication type" + }, + "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" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": { + "description" : "The operation definition and data (action-data pairs), separated by newlines", + "required" : true, + "serialize" : "bulk" + } + } +} diff --git a/rest-api-spec/api/cat.aliases.json b/rest-api-spec/api/cat.aliases.json new file mode 100644 index 0000000..4df8e1e --- /dev/null +++ b/rest-api-spec/api/cat.aliases.json @@ -0,0 +1,41 @@ +{ + "cat.aliases": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-aliases.html", + "methods": ["GET"], + "url": { + "path": "/_cat/aliases", + "paths": ["/_cat/aliases", "/_cat/aliases/{name}"], + "parts": { + "name": { + "type" : "list", + "description" : "A comma-separated list of alias names to return" + } + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.allocation.json b/rest-api-spec/api/cat.allocation.json new file mode 100644 index 0000000..c2783e1 --- /dev/null +++ b/rest-api-spec/api/cat.allocation.json @@ -0,0 +1,46 @@ +{ + "cat.allocation": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-allocation.html", + "methods": ["GET"], + "url": { + "path": "/_cat/allocation", + "paths": ["/_cat/allocation", "/_cat/allocation/{node_id}"], + "parts": { + "node_id": { + "type": "list", + "description": "A comma-separated list of node IDs or names to limit the returned information" + } + }, + "params": { + "bytes": { + "type": "enum", + "description" : "The unit in which to display byte values", + "options": [ "b", "k", "m", "g" ] + }, + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.count.json b/rest-api-spec/api/cat.count.json new file mode 100644 index 0000000..6b5b7d7 --- /dev/null +++ b/rest-api-spec/api/cat.count.json @@ -0,0 +1,41 @@ +{ + "cat.count": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-count.html", + "methods": ["GET"], + "url": { + "path": "/_cat/count", + "paths": ["/_cat/count", "/_cat/count/{index}"], + "parts": { + "index": { + "type" : "list", + "description": "A comma-separated list of index names to limit the returned information" + } + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.health.json b/rest-api-spec/api/cat.health.json new file mode 100644 index 0000000..f8d73ae --- /dev/null +++ b/rest-api-spec/api/cat.health.json @@ -0,0 +1,42 @@ +{ + "cat.health": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-health.html", + "methods": ["GET"], + "url": { + "path": "/_cat/health", + "paths": ["/_cat/health"], + "parts": { + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "ts": { + "type": "boolean", + "description": "Set to false to disable timestamping", + "default": true + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.help.json b/rest-api-spec/api/cat.help.json new file mode 100644 index 0000000..d7f2913 --- /dev/null +++ b/rest-api-spec/api/cat.help.json @@ -0,0 +1,20 @@ +{ + "cat.help": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat.html", + "methods": ["GET"], + "url": { + "path": "/_cat", + "paths": ["/_cat"], + "parts": { + }, + "params": { + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.indices.json b/rest-api-spec/api/cat.indices.json new file mode 100644 index 0000000..55fb1c6 --- /dev/null +++ b/rest-api-spec/api/cat.indices.json @@ -0,0 +1,51 @@ +{ + "cat.indices": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-indices.html", + "methods": ["GET"], + "url": { + "path": "/_cat/indices", + "paths": ["/_cat/indices", "/_cat/indices/{index}"], + "parts": { + "index": { + "type" : "list", + "description": "A comma-separated list of index names to limit the returned information" + } + }, + "params": { + "bytes": { + "type": "enum", + "description" : "The unit in which to display byte values", + "options": [ "b", "k", "m", "g" ] + }, + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "pri" : { + "type": "boolean", + "description": "Set to true to return stats only for primary shards", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.master.json b/rest-api-spec/api/cat.master.json new file mode 100644 index 0000000..83b8821 --- /dev/null +++ b/rest-api-spec/api/cat.master.json @@ -0,0 +1,37 @@ +{ + "cat.master": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-master.html", + "methods": ["GET"], + "url": { + "path": "/_cat/master", + "paths": ["/_cat/master"], + "parts": { + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.nodes.json b/rest-api-spec/api/cat.nodes.json new file mode 100644 index 0000000..a458165 --- /dev/null +++ b/rest-api-spec/api/cat.nodes.json @@ -0,0 +1,37 @@ +{ + "cat.nodes": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-nodes.html", + "methods": ["GET"], + "url": { + "path": "/_cat/nodes", + "paths": ["/_cat/nodes"], + "parts": { + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.pending_tasks.json b/rest-api-spec/api/cat.pending_tasks.json new file mode 100644 index 0000000..7e2c6b4 --- /dev/null +++ b/rest-api-spec/api/cat.pending_tasks.json @@ -0,0 +1,37 @@ +{ + "cat.pending_tasks": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-pending-tasks.html", + "methods": ["GET"], + "url": { + "path": "/_cat/pending_tasks", + "paths": ["/_cat/pending_tasks"], + "parts": { + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.recovery.json b/rest-api-spec/api/cat.recovery.json new file mode 100644 index 0000000..70f69a5 --- /dev/null +++ b/rest-api-spec/api/cat.recovery.json @@ -0,0 +1,46 @@ +{ + "cat.recovery": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-recovery.html", + "methods": ["GET"], + "url": { + "path": "/_cat/recovery", + "paths": ["/_cat/recovery", "/_cat/recovery/{index}"], + "parts": { + "index": { + "type" : "list", + "description": "A comma-separated list of index names to limit the returned information" + } + }, + "params": { + "bytes": { + "type": "enum", + "description" : "The unit in which to display byte values", + "options": [ "b", "k", "m", "g" ] + }, + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.shards.json b/rest-api-spec/api/cat.shards.json new file mode 100644 index 0000000..df3825f --- /dev/null +++ b/rest-api-spec/api/cat.shards.json @@ -0,0 +1,41 @@ +{ + "cat.shards": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cat-shards.html", + "methods": ["GET"], + "url": { + "path": "/_cat/shards", + "paths": ["/_cat/shards", "/_cat/shards/{index}"], + "parts": { + "index": { + "type" : "list", + "description": "A comma-separated list of index names to limit the returned information" + } + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cat.thread_pool.json b/rest-api-spec/api/cat.thread_pool.json new file mode 100644 index 0000000..a0bd786 --- /dev/null +++ b/rest-api-spec/api/cat.thread_pool.json @@ -0,0 +1,42 @@ +{ + "cat.thread_pool": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-thread-pool.html", + "methods": ["GET"], + "url": { + "path": "/_cat/thread_pool", + "paths": ["/_cat/thread_pool"], + "parts": { + }, + "params": { + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "h": { + "type": "list", + "description" : "Comma-separated list of column names to display" + }, + "help": { + "type": "boolean", + "description": "Return help information", + "default": false + }, + "v": { + "type": "boolean", + "description": "Verbose mode. Display column headers", + "default": false + }, + "full_id": { + "type": "boolean", + "description": "Enables displaying the complete node ids", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/clear_scroll.json b/rest-api-spec/api/clear_scroll.json new file mode 100644 index 0000000..403d231 --- /dev/null +++ b/rest-api-spec/api/clear_scroll.json @@ -0,0 +1,21 @@ +{ + "clear_scroll": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-scroll.html", + "methods": ["DELETE"], + "url": { + "path": "/_search/scroll/{scroll_id}", + "paths": ["/_search/scroll/{scroll_id}"], + "parts": { + "scroll_id": { + "type" : "list", + "required" : "true", + "description" : "A comma-separated list of scroll IDs to clear" + } + }, + "params": {} + }, + "body": { + "description": "A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter" + } + } +} diff --git a/rest-api-spec/api/cluster.get_settings.json b/rest-api-spec/api/cluster.get_settings.json new file mode 100644 index 0000000..98e2b3b --- /dev/null +++ b/rest-api-spec/api/cluster.get_settings.json @@ -0,0 +1,26 @@ +{ + "cluster.get_settings": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html", + "methods": ["GET"], + "url": { + "path": "/_cluster/settings", + "paths": ["/_cluster/settings"], + "parts": {}, + "params": { + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cluster.health.json b/rest-api-spec/api/cluster.health.json new file mode 100644 index 0000000..9d679d6 --- /dev/null +++ b/rest-api-spec/api/cluster.health.json @@ -0,0 +1,55 @@ +{ + "cluster.health": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-health.html", + "methods": ["GET"], + "url": { + "path": "/_cluster/health", + "paths": ["/_cluster/health", "/_cluster/health/{index}"], + "parts": { + "index": { + "type" : "string", + "description" : "Limit the information returned to a specific index" + } + }, + "params": { + "level": { + "type" : "enum", + "options" : ["cluster","indices","shards"], + "default" : "cluster", + "description" : "Specify the level of detail for returned information" + }, + "local": { + "type" : "boolean", + "description" : "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "wait_for_active_shards": { + "type" : "number", + "description" : "Wait until the specified number of shards is active" + }, + "wait_for_nodes": { + "type" : "string", + "description" : "Wait until the specified number of nodes is available" + }, + "wait_for_relocating_shards": { + "type" : "number", + "description" : "Wait until the specified number of relocating shards is finished" + }, + "wait_for_status": { + "type" : "enum", + "options" : ["green","yellow","red"], + "default" : null, + "description" : "Wait until cluster is in a specific state" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cluster.pending_tasks.json b/rest-api-spec/api/cluster.pending_tasks.json new file mode 100644 index 0000000..09a5fe7 --- /dev/null +++ b/rest-api-spec/api/cluster.pending_tasks.json @@ -0,0 +1,23 @@ +{ + "cluster.pending_tasks": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-pending.html", + "methods": ["GET"], + "url": { + "path": "/_cluster/pending_tasks", + "paths": ["/_cluster/pending_tasks"], + "parts": { + }, + "params": { + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type": "time", + "description": "Specify timeout for connection to master" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cluster.put_settings.json b/rest-api-spec/api/cluster.put_settings.json new file mode 100644 index 0000000..a832c4d --- /dev/null +++ b/rest-api-spec/api/cluster.put_settings.json @@ -0,0 +1,20 @@ +{ + "cluster.put_settings": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-update-settings.html", + "methods": ["PUT"], + "url": { + "path": "/_cluster/settings", + "paths": ["/_cluster/settings"], + "parts": {}, + "params": { + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + } + } + }, + "body": { + "description": "The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart)." + } + } +} diff --git a/rest-api-spec/api/cluster.reroute.json b/rest-api-spec/api/cluster.reroute.json new file mode 100644 index 0000000..9adf747 --- /dev/null +++ b/rest-api-spec/api/cluster.reroute.json @@ -0,0 +1,33 @@ +{ + "cluster.reroute": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-reroute.html", + "methods": ["POST"], + "url": { + "path": "/_cluster/reroute", + "paths": ["/_cluster/reroute"], + "parts": { + }, + "params": { + "dry_run": { + "type" : "boolean", + "description" : "Simulate the operation only and return the resulting state" + }, + "filter_metadata": { + "type" : "boolean", + "description" : "Don't return cluster state metadata (default: false)" + }, + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": { + "description" : "The definition of `commands` to perform (`move`, `cancel`, `allocate`)" + } + } +} diff --git a/rest-api-spec/api/cluster.state.json b/rest-api-spec/api/cluster.state.json new file mode 100644 index 0000000..dcf0182 --- /dev/null +++ b/rest-api-spec/api/cluster.state.json @@ -0,0 +1,44 @@ +{ + "cluster.state": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-state.html", + "methods": ["GET"], + "url": { + "path": "/_cluster/state", + "paths": [ + "/_cluster/state", + "/_cluster/state/{metric}", + "/_cluster/state/{metric}/{index}" + ], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + }, + "metric" : { + "type" : "list", + "options" : ["_all", "blocks", "metadata", "nodes", "routing_table", "master_node", "version"], + "description" : "Limit the information returned to the specified metrics" + } + }, + "params": { + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + }, + "master_timeout": { + "type": "time", + "description": "Specify timeout for connection to master" + }, + "index_templates": { + "type": "list", + "description": "A comma separated list to return specific index templates when returning metadata" + }, + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/cluster.stats.json b/rest-api-spec/api/cluster.stats.json new file mode 100644 index 0000000..8964b58 --- /dev/null +++ b/rest-api-spec/api/cluster.stats.json @@ -0,0 +1,28 @@ +{ + "cluster.stats": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-stats.html", + "methods": ["GET"], + "url": { + "path": "/_cluster/stats", + "paths": ["/_cluster/stats", "/_cluster/stats/nodes/{node_id}"], + "parts": { + "node_id": { + "type" : "list", + "description" : "A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes" + } + }, + "params": { + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + }, + "human": { + "type": "boolean", + "description": "Whether to return time and byte values in human-readable format.", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/count.json b/rest-api-spec/api/count.json new file mode 100644 index 0000000..90e5e9d --- /dev/null +++ b/rest-api-spec/api/count.json @@ -0,0 +1,55 @@ +{ + "count": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-count.html", + "methods": ["POST", "GET"], + "url": { + "path": "/_count", + "paths": ["/_count", "/{index}/_count", "/{index}/{type}/_count"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of indices to restrict the results" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of types to restrict the results" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "min_score": { + "type" : "number", + "description" : "Include only documents with a specific `_score` value in the result" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "source": { + "type" : "string", + "description" : "The URL-encoded query definition (instead of using the request body)" + } + } + }, + "body": { + "description" : "A query to restrict the results specified with the Query DSL (optional)" + } + } +} diff --git a/rest-api-spec/api/count_percolate.json b/rest-api-spec/api/count_percolate.json new file mode 100644 index 0000000..3ab4cd5 --- /dev/null +++ b/rest-api-spec/api/count_percolate.json @@ -0,0 +1,72 @@ +{ + "count_percolate": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-percolate.html", + "methods": ["GET", "POST"], + "url": { + "path": "/{index}/{type}/_percolate/count", + "paths": ["/{index}/{type}/_percolate/count", "/{index}/{type}/{id}/_percolate/count"], + "parts": { + "index": { + "type": "string", + "required": true, + "description": "The index of the document being count percolated." + }, + "type": { + "type": "string", + "required": true, + "description": "The type of the document being count percolated." + }, + "id": { + "type": "string", + "required": false, + "description": "Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster." + } + }, + "params": { + "routing": { + "type": "list", + "description": "A comma-separated list of specific routing values" + }, + "preference": { + "type": "string", + "description": "Specify the node or shard the operation should be performed on (default: random)" + }, + "ignore_unavailable": { + "type": "boolean", + "description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type": "boolean", + "description": "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type": "enum", + "options": ["open", "closed"], + "default": "open", + "description": "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "percolate_index": { + "type": "string", + "description": "The index to count percolate the document into. Defaults to index." + }, + "percolate_type": { + "type": "string", + "description": "The type to count percolate document into. Defaults to type." + }, + "version": { + "type": "number", + "description": "Explicit version number for concurrency control" + }, + "version_type": { + "type": "enum", + "options": ["internal", "external"], + "description": "Specific version type" + } + } + }, + "body": { + "description": "The count percolator request definition using the percolate DSL", + "required": false + } + } +} diff --git a/rest-api-spec/api/delete.json b/rest-api-spec/api/delete.json new file mode 100644 index 0000000..6c168c7 --- /dev/null +++ b/rest-api-spec/api/delete.json @@ -0,0 +1,66 @@ +{ + "delete": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-delete.html", + "methods": ["DELETE"], + "url": { + "path": "/{index}/{type}/{id}", + "paths": ["/{index}/{type}/{id}"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "description" : "The 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" : "Specific write consistency setting for the operation" + }, + "parent": { + "type" : "string", + "description" : "ID of parent document" + }, + "refresh": { + "type" : "boolean", + "description" : "Refresh the index after performing the operation" + }, + "replication": { + "type" : "enum", + "options" : ["sync","async"], + "default" : "sync", + "description" : "Specific replication type" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "version" : { + "type" : "number", + "description" : "Explicit version number for concurrency control" + }, + "version_type": { + "type" : "enum", + "options" : ["internal","external"], + "description" : "Specific version type" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/delete_by_query.json b/rest-api-spec/api/delete_by_query.json new file mode 100644 index 0000000..3480b7e --- /dev/null +++ b/rest-api-spec/api/delete_by_query.json @@ -0,0 +1,81 @@ +{ + "delete_by_query": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-delete-by-query.html", + "methods": ["DELETE"], + "url": { + "path": "/{index}/_query", + "paths": ["/{index}/_query", "/{index}/{type}/_query"], + "parts": { + "index": { + "type" : "list", + "required": true, + "description" : "A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of types to restrict the operation" + } + }, + "params": { + "analyzer": { + "type" : "string", + "description" : "The analyzer to use for the query string" + }, + "consistency": { + "type" : "enum", + "options" : ["one", "quorum", "all"], + "description" : "Specific write consistency setting for the operation" + }, + "default_operator": { + "type" : "enum", + "options" : ["AND","OR"], + "default" : "OR", + "description" : "The default operator for query string query (AND or OR)" + }, + "df": { + "type" : "string", + "description" : "The field to use as default where no field prefix is given in the query string" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "replication": { + "type" : "enum", + "options" : ["sync","async"], + "default" : "sync", + "description" : "Specific replication type" + }, + "q": { + "type" : "string", + "description" : "Query in the Lucene query string syntax" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "source": { + "type" : "string", + "description" : "The URL-encoded query definition (instead of using the request body)" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": { + "description" : "A query to restrict the operation specified with the Query DSL" + } + } +} diff --git a/rest-api-spec/api/exists.json b/rest-api-spec/api/exists.json new file mode 100644 index 0000000..b7ba649 --- /dev/null +++ b/rest-api-spec/api/exists.json @@ -0,0 +1,50 @@ +{ + "exists": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-get.html", + "methods": ["HEAD"], + "url": { + "path": "/{index}/{type}/{id}", + "paths": ["/{index}/{type}/{id}"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "description" : "The document ID" + }, + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + }, + "type": { + "type" : "string", + "required" : true, + "description" : "The type of the document (use `_all` to fetch the first document matching the ID across all types)" + } + }, + "params": { + "parent": { + "type" : "string", + "description" : "The ID of the parent document" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "realtime": { + "type" : "boolean", + "description" : "Specify whether to perform the operation in realtime or search mode" + }, + "refresh": { + "type" : "boolean", + "description" : "Refresh the shard containing the document before performing the operation" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/explain.json b/rest-api-spec/api/explain.json new file mode 100644 index 0000000..bee897b --- /dev/null +++ b/rest-api-spec/api/explain.json @@ -0,0 +1,94 @@ +{ + "explain": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-explain.html", + "methods": ["GET", "POST"], + "url": { + "path": "/{index}/{type}/{id}/_explain", + "paths": ["/{index}/{type}/{id}/_explain"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "description" : "The 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": { + "analyze_wildcard": { + "type" : "boolean", + "description" : "Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)" + }, + "analyzer": { + "type" : "string", + "description" : "The analyzer for the query string query" + }, + "default_operator": { + "type" : "enum", + "options" : ["AND","OR"], + "default" : "OR", + "description" : "The default operator for query string query (AND or OR)" + }, + "df": { + "type" : "string", + "description" : "The default field for query string query (default: _all)" + }, + "fields": { + "type": "list", + "description" : "A comma-separated list of fields to return in the response" + }, + "lenient": { + "type" : "boolean", + "description" : "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored" + }, + "lowercase_expanded_terms": { + "type" : "boolean", + "description" : "Specify whether query terms should be lowercased" + }, + "parent": { + "type" : "string", + "description" : "The ID of the parent document" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "q": { + "type" : "string", + "description" : "Query in the Lucene query string syntax" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "source": { + "type" : "string", + "description" : "The URL-encoded query definition (instead of using the request body)" + }, + "_source": { + "type" : "list", + "description" : "True or false to return the _source field or not, or a list of fields to return" + }, + "_source_exclude": { + "type" : "list", + "description" : "A list of fields to exclude from the returned _source field" + }, + "_source_include": { + "type" : "list", + "description" : "A list of fields to extract and return from the _source field" + } + } + }, + "body": { + "description" : "The query definition using the Query DSL" + } + } +} diff --git a/rest-api-spec/api/get.json b/rest-api-spec/api/get.json new file mode 100644 index 0000000..888f528 --- /dev/null +++ b/rest-api-spec/api/get.json @@ -0,0 +1,75 @@ +{ + "get": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-get.html", + "methods": ["GET"], + "url": { + "path": "/{index}/{type}/{id}", + "paths": ["/{index}/{type}/{id}"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "description" : "The document ID" + }, + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + }, + "type": { + "type" : "string", + "required" : true, + "description" : "The type of the document (use `_all` to fetch the first document matching the ID across all types)" + } + }, + "params": { + "fields": { + "type": "list", + "description" : "A comma-separated list of fields to return in the response" + }, + "parent": { + "type" : "string", + "description" : "The ID of the parent document" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "realtime": { + "type" : "boolean", + "description" : "Specify whether to perform the operation in realtime or search mode" + }, + "refresh": { + "type" : "boolean", + "description" : "Refresh the shard containing the document before performing the operation" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "_source": { + "type" : "list", + "description" : "True or false to return the _source field or not, or a list of fields to return" + }, + "_source_exclude": { + "type" : "list", + "description" : "A list of fields to exclude from the returned _source field" + }, + "_source_include": { + "type" : "list", + "description" : "A list of fields to extract and return from the _source field" + }, + "version" : { + "type" : "number", + "description" : "Explicit version number for concurrency control" + }, + "version_type": { + "type" : "enum", + "options" : ["internal","external"], + "description" : "Specific version type" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/get_source.json b/rest-api-spec/api/get_source.json new file mode 100644 index 0000000..8f37a77 --- /dev/null +++ b/rest-api-spec/api/get_source.json @@ -0,0 +1,71 @@ +{ + "get_source": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-get.html", + "methods": ["GET"], + "url": { + "path": "/{index}/{type}/{id}/_source", + "paths": ["/{index}/{type}/{id}/_source"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "description" : "The document ID" + }, + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + }, + "type": { + "type" : "string", + "required" : true, + "description" : "The type of the document; use `_all` to fetch the first document matching the ID across all types" + } + }, + "params": { + "parent": { + "type" : "string", + "description" : "The ID of the parent document" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "realtime": { + "type" : "boolean", + "description" : "Specify whether to perform the operation in realtime or search mode" + }, + "refresh": { + "type" : "boolean", + "description" : "Refresh the shard containing the document before performing the operation" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "_source": { + "type" : "list", + "description" : "True or false to return the _source field or not, or a list of fields to return" + }, + "_source_exclude": { + "type" : "list", + "description" : "A list of fields to exclude from the returned _source field" + }, + "_source_include": { + "type" : "list", + "description" : "A list of fields to extract and return from the _source field" + }, + "version" : { + "type" : "number", + "description" : "Explicit version number for concurrency control" + }, + "version_type": { + "type" : "enum", + "options" : ["internal","external"], + "description" : "Specific version type" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/index.json b/rest-api-spec/api/index.json new file mode 100644 index 0000000..1627bdd --- /dev/null +++ b/rest-api-spec/api/index.json @@ -0,0 +1,82 @@ +{ + "index": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-index_.html", + "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" + }, + "replication": { + "type" : "enum", + "options" : ["sync","async"], + "default" : "sync", + "description" : "Specific replication type" + }, + "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"], + "description" : "Specific version type" + } + } + }, + "body": { + "description" : "The document", + "required" : true + } + } +} diff --git a/rest-api-spec/api/indices.analyze.json b/rest-api-spec/api/indices.analyze.json new file mode 100644 index 0000000..f9db551 --- /dev/null +++ b/rest-api-spec/api/indices.analyze.json @@ -0,0 +1,55 @@ +{ + "indices.analyze": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-analyze.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_analyze", + "paths": ["/_analyze", "/{index}/_analyze"], + "parts": { + "index": { + "type" : "string", + "description" : "The name of the index to scope the operation" + } + }, + "params": { + "analyzer": { + "type" : "string", + "description" : "The name of the analyzer to use" + }, + "field": { + "type" : "string", + "description" : "Use the analyzer configured for this field (instead of passing the analyzer name)" + }, + "filters": { + "type" : "list", + "description" : "A comma-separated list of filters to use for the analysis" + }, + "index": { + "type" : "string", + "description" : "The name of the index to scope the operation" + }, + "prefer_local": { + "type" : "boolean", + "description" : "With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)" + }, + "text": { + "type" : "string", + "description" : "The text on which the analysis should be performed (when request body is not used)" + }, + "tokenizer": { + "type" : "string", + "description" : "The name of the tokenizer to use for the analysis" + }, + "format": { + "type": "enum", + "options" : ["detailed","text"], + "default": "detailed", + "description": "Format of the output" + } + } + }, + "body": { + "description" : "The text on which the analysis should be performed" + } + } +} diff --git a/rest-api-spec/api/indices.clear_cache.json b/rest-api-spec/api/indices.clear_cache.json new file mode 100644 index 0000000..36bf1ff --- /dev/null +++ b/rest-api-spec/api/indices.clear_cache.json @@ -0,0 +1,73 @@ +{ + "indices.clear_cache": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-clearcache.html", + "methods": ["POST", "GET"], + "url": { + "path": "/_cache/clear", + "paths": ["/_cache/clear", "/{index}/_cache/clear"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index name to limit the operation" + } + }, + "params": { + "field_data": { + "type" : "boolean", + "description" : "Clear field data" + }, + "fielddata": { + "type" : "boolean", + "description" : "Clear field data" + }, + "fields": { + "type" : "list", + "description" : "A comma-separated list of fields to clear when using the `field_data` parameter (default: all)" + }, + "filter": { + "type" : "boolean", + "description" : "Clear filter caches" + }, + "filter_cache": { + "type" : "boolean", + "description" : "Clear filter caches" + }, + "filter_keys": { + "type" : "boolean", + "description" : "A comma-separated list of keys to clear when using the `filter_cache` parameter (default: all)" + }, + "id": { + "type" : "boolean", + "description" : "Clear ID caches for parent/child" + }, + "id_cache": { + "type" : "boolean", + "description" : "Clear ID caches for parent/child" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "index": { + "type" : "list", + "description" : "A comma-separated list of index name to limit the operation" + }, + "recycler": { + "type" : "boolean", + "description" : "Clear the recycler cache" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.close.json b/rest-api-spec/api/indices.close.json new file mode 100644 index 0000000..d26afac --- /dev/null +++ b/rest-api-spec/api/indices.close.json @@ -0,0 +1,42 @@ +{ + "indices.close": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-open-close.html", + "methods": ["POST"], + "url": { + "path": "/{index}/_close", + "paths": ["/{index}/_close"], + "parts": { + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.create.json b/rest-api-spec/api/indices.create.json new file mode 100644 index 0000000..33c02f2 --- /dev/null +++ b/rest-api-spec/api/indices.create.json @@ -0,0 +1,30 @@ +{ + "indices.create": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-create-index.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/{index}", + "paths": ["/{index}"], + "parts": { + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": { + "description" : "The configuration for the index (`settings` and `mappings`)" + } + } +} diff --git a/rest-api-spec/api/indices.delete.json b/rest-api-spec/api/indices.delete.json new file mode 100644 index 0000000..aa904ca --- /dev/null +++ b/rest-api-spec/api/indices.delete.json @@ -0,0 +1,27 @@ +{ + "indices.delete": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-delete-index.html", + "methods": ["DELETE"], + "url": { + "path": "/{index}", + "paths": ["/{index}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.delete_alias.json b/rest-api-spec/api/indices.delete_alias.json new file mode 100644 index 0000000..0b26ad5 --- /dev/null +++ b/rest-api-spec/api/indices.delete_alias.json @@ -0,0 +1,33 @@ +{ + "indices.delete_alias": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-aliases.html", + "methods": ["DELETE"], + "url": { + "path": "/{index}/_alias/{name}", + "paths": ["/{index}/_alias/{name}", "/{index}/_aliases/{name}"], + "parts": { + "index": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of index names (supports wildcards); use `_all` for all indices" + }, + "name": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices." + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit timestamp for the document" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.delete_mapping.json b/rest-api-spec/api/indices.delete_mapping.json new file mode 100644 index 0000000..e1cce4b --- /dev/null +++ b/rest-api-spec/api/indices.delete_mapping.json @@ -0,0 +1,29 @@ +{ + "indices.delete_mapping": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-delete-mapping.html", + "methods": ["DELETE"], + "url": { + "path": "/{index}/{type}/_mapping", + "paths": ["/{index}/{type}/_mapping", "/{index}/{type}", "/{index}/_mapping/{type}", "/{index}/{type}/_mappings", "/{index}/_mappings/{type}"], + "parts": { + "index": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of index names (supports wildcards); use `_all` for all indices" + }, + "type": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of document types to delete (supports wildcards); use `_all` to delete all document types in the specified indices." + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.delete_template.json b/rest-api-spec/api/indices.delete_template.json new file mode 100644 index 0000000..f012f0a --- /dev/null +++ b/rest-api-spec/api/indices.delete_template.json @@ -0,0 +1,28 @@ +{ + "indices.delete_template": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-templates.html", + "methods": ["DELETE"], + "url": { + "path": "/_template/{name}", + "paths": ["/_template/{name}"], + "parts": { + "name": { + "type" : "string", + "required" : true, + "description" : "The name of the template" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.delete_warmer.json b/rest-api-spec/api/indices.delete_warmer.json new file mode 100644 index 0000000..f05a144 --- /dev/null +++ b/rest-api-spec/api/indices.delete_warmer.json @@ -0,0 +1,33 @@ +{ + "indices.delete_warmer": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-warmers.html", + "methods": ["DELETE"], + "url": { + "path": "/{index}/_warmer/{name}", + "paths": ["/{index}/_warmer/{name}", "/{index}/_warmers/{name}"], + "parts": { + "index": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of index names to delete warmers from (supports wildcards); use `_all` to perform the operation on all indices." + }, + "name" : { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of warmer names to delete (supports wildcards); use `_all` to delete all warmers in the specified indices. You must specify a name either in the uri or in the parameters." + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + }, + "name" : { + "type" : "list", + "description" : "A comma-separated list of warmer names to delete (supports wildcards); use `_all` to delete all warmers in the specified indices. You must specify a name either in the uri or in the parameters." + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.exists.json b/rest-api-spec/api/indices.exists.json new file mode 100644 index 0000000..a0f4a8f --- /dev/null +++ b/rest-api-spec/api/indices.exists.json @@ -0,0 +1,38 @@ +{ + "indices.exists": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-get-settings.html", + "methods": ["HEAD"], + "url": { + "path": "/{index}", + "paths": ["/{index}"], + "parts": { + "index": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of indices to check" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.exists_alias.json b/rest-api-spec/api/indices.exists_alias.json new file mode 100644 index 0000000..2ee8789 --- /dev/null +++ b/rest-api-spec/api/indices.exists_alias.json @@ -0,0 +1,41 @@ +{ + "indices.exists_alias": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-aliases.html", + "methods": ["HEAD"], + "url": { + "path": "/_alias/{name}", + "paths": ["/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"], + "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 return" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : ["open", "closed"], + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.exists_template.json b/rest-api-spec/api/indices.exists_template.json new file mode 100644 index 0000000..0c0b74e --- /dev/null +++ b/rest-api-spec/api/indices.exists_template.json @@ -0,0 +1,24 @@ +{ + "indices.exists_template": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-templates.html", + "methods": ["HEAD"], + "url": { + "path": "/_template/{name}", + "paths": ["/_template/{name}"], + "parts": { + "name": { + "type" : "string", + "required" : true, + "description" : "The name of the template" + } + }, + "params": { + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.exists_type.json b/rest-api-spec/api/indices.exists_type.json new file mode 100644 index 0000000..da722aa --- /dev/null +++ b/rest-api-spec/api/indices.exists_type.json @@ -0,0 +1,43 @@ +{ + "indices.exists_type": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-types-exists.html", + "methods": ["HEAD"], + "url": { + "path": "/{index}/{type}", + "paths": ["/{index}/{type}"], + "parts": { + "index": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of index names; use `_all` to check the types across all indices" + }, + "type": { + "type" : "list", + "required" : true, + "description" : "A comma-separated list of document types to check" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.flush.json b/rest-api-spec/api/indices.flush.json new file mode 100644 index 0000000..b0f16ca --- /dev/null +++ b/rest-api-spec/api/indices.flush.json @@ -0,0 +1,41 @@ +{ + "indices.flush": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-flush.html", + "methods": ["POST", "GET"], + "url": { + "path": "/_flush", + "paths": ["/_flush", "/{index}/_flush"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string for all indices" + } + }, + "params": { + "force": { + "type" : "boolean", + "description" : "Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal)" + }, + "full": { + "type" : "boolean", + "description" : "If set to true a new index writer is created and settings that have been changed related to the index writer will be refreshed. Note: if a full flush is required for a setting to take effect this will be part of the settings update process and it not required to be executed by the user. (This setting can be considered as internal)" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_alias.json b/rest-api-spec/api/indices.get_alias.json new file mode 100644 index 0000000..0a76bdf --- /dev/null +++ b/rest-api-spec/api/indices.get_alias.json @@ -0,0 +1,41 @@ +{ + "indices.get_alias": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-aliases.html", + "methods": ["GET"], + "url": { + "path": "/_alias/", + "paths": [ "/_alias", "/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"], + "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 return" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_aliases.json b/rest-api-spec/api/indices.get_aliases.json new file mode 100644 index 0000000..f79aed9 --- /dev/null +++ b/rest-api-spec/api/indices.get_aliases.json @@ -0,0 +1,31 @@ +{ + "indices.get_aliases": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-aliases.html", + "methods": ["GET"], + "url": { + "path": "/_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": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_field_mapping.json b/rest-api-spec/api/indices.get_field_mapping.json new file mode 100644 index 0000000..20728b6 --- /dev/null +++ b/rest-api-spec/api/indices.get_field_mapping.json @@ -0,0 +1,50 @@ +{ + "indices.get_field_mapping": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-get-field-mapping.html", + "methods": ["GET"], + "url": { + "path": "/_mapping/field/{field}", + "paths": ["/_mapping/field/{field}", "/{index}/_mapping/field/{field}", "/_mapping/{type}/field/{field}", "/{index}/_mapping/{type}/field/{field}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types" + }, + "field": { + "type" : "list", + "description" : "A comma-separated list of fields", + "required" : true + } + }, + "params": { + "include_defaults": { + "type" : "boolean", + "description" : "Whether the default mapping values should be returned as well" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_mapping.json b/rest-api-spec/api/indices.get_mapping.json new file mode 100644 index 0000000..0e6f011 --- /dev/null +++ b/rest-api-spec/api/indices.get_mapping.json @@ -0,0 +1,41 @@ +{ + "indices.get_mapping": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-get-mapping.html", + "methods": ["GET"], + "url": { + "path": "/_mapping", + "paths": ["/_mapping", "/{index}/_mapping", "/_mapping/{type}", "/{index}/_mapping/{type}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_settings.json b/rest-api-spec/api/indices.get_settings.json new file mode 100644 index 0000000..d9b8d40 --- /dev/null +++ b/rest-api-spec/api/indices.get_settings.json @@ -0,0 +1,45 @@ +{ + "indices.get_settings": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-get-mapping.html", + "methods": ["GET"], + "url": { + "path": "/_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" + }, + "name": { + "type" : "list", + "description" : "The name of the settings that should be included" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : ["open","closed"], + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_template.json b/rest-api-spec/api/indices.get_template.json new file mode 100644 index 0000000..0a4a008 --- /dev/null +++ b/rest-api-spec/api/indices.get_template.json @@ -0,0 +1,28 @@ +{ + "indices.get_template": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-templates.html", + "methods": ["GET"], + "url": { + "path": "/_template/{name}", + "paths": ["/_template", "/_template/{name}"], + "parts": { + "name": { + "type" : "string", + "required" : false, + "description" : "The name of the template" + } + }, + "params": { + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.get_warmer.json b/rest-api-spec/api/indices.get_warmer.json new file mode 100644 index 0000000..7d5fd49 --- /dev/null +++ b/rest-api-spec/api/indices.get_warmer.json @@ -0,0 +1,45 @@ +{ + "indices.get_warmer": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-warmers.html", + "methods": ["GET"], + "url": { + "path": "/_warmer", + "paths": [ "/_warmer", "/{index}/_warmer", "/{index}/_warmer/{name}", "/_warmer/{name}", "/{index}/{type}/_warmer/{name}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to restrict the operation; use `_all` to perform the operation on all indices" + }, + "name": { + "type" : "list", + "description" : "The name of the warmer (supports wildcards); leave empty to get all warmers" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.open.json b/rest-api-spec/api/indices.open.json new file mode 100644 index 0000000..7d1c275 --- /dev/null +++ b/rest-api-spec/api/indices.open.json @@ -0,0 +1,42 @@ +{ + "indices.open": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-open-close.html", + "methods": ["POST"], + "url": { + "path": "/{index}/_open", + "paths": ["/{index}/_open"], + "parts": { + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "closed", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.optimize.json b/rest-api-spec/api/indices.optimize.json new file mode 100644 index 0000000..fb6bd86 --- /dev/null +++ b/rest-api-spec/api/indices.optimize.json @@ -0,0 +1,52 @@ +{ + "indices.optimize": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-optimize.html", + "methods": ["POST", "GET"], + "url": { + "path": "/_optimize", + "paths": ["/_optimize", "/{index}/_optimize"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + } + }, + "params": { + "flush": { + "type" : "boolean", + "description" : "Specify whether the index should be flushed after performing the operation (default: true)" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "max_num_segments": { + "type" : "number", + "description" : "The number of segments the index should be merged into (default: dynamic)" + }, + "only_expunge_deletes": { + "type" : "boolean", + "description" : "Specify whether the operation should only expunge deleted documents" + }, + "operation_threading": { + "description" : "TODO: ?" + }, + "wait_for_merge": { + "type" : "boolean", + "description" : "Specify whether the request should block until the merge process is finished (default: true)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.put_alias.json b/rest-api-spec/api/indices.put_alias.json new file mode 100644 index 0000000..eb78de6 --- /dev/null +++ b/rest-api-spec/api/indices.put_alias.json @@ -0,0 +1,35 @@ +{ + "indices.put_alias": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-aliases.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/{index}/_alias/{name}", + "paths": ["/{index}/_alias/{name}", "/_alias/{name}", "/{index}/_aliases/{name}", "/_aliases/{name}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names the alias should point to (supports wildcards); use `_all` or omit to perform the operation on all indices." + }, + "name": { + "type" : "string", + "required" : true, + "description" : "The name of the alias to be created or updated" + } + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Explicit timestamp for the document" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": { + "description" : "The settings for the alias, such as `routing` or `filter`", + "required" : false + } + } +} diff --git a/rest-api-spec/api/indices.put_mapping.json b/rest-api-spec/api/indices.put_mapping.json new file mode 100644 index 0000000..891bca0 --- /dev/null +++ b/rest-api-spec/api/indices.put_mapping.json @@ -0,0 +1,53 @@ +{ + "indices.put_mapping": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-put-mapping.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/{index}/{type}/_mapping", + "paths": ["/{index}/{type}/_mapping", "/{index}/_mapping/{type}", "/_mapping/{type}", "/{index}/{type}/_mappings", "/{index}/_mappings/{type}", "/_mappings/{type}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices." + }, + "type": { + "type" : "string", + "required" : true, + "description" : "The name of the document type" + } + }, + "params": { + "ignore_conflicts": { + "type" : "boolean", + "description" : "Specify whether to ignore conflicts while updating the mapping (default: false)" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": { + "description" : "The mapping definition", + "required" : true + } + } +} diff --git a/rest-api-spec/api/indices.put_settings.json b/rest-api-spec/api/indices.put_settings.json new file mode 100644 index 0000000..81b9a5c --- /dev/null +++ b/rest-api-spec/api/indices.put_settings.json @@ -0,0 +1,44 @@ +{ + "indices.put_settings": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-update-settings.html", + "methods": ["PUT"], + "url": { + "path": "/_settings", + "paths": ["/_settings", "/{index}/_settings"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + } + }, + "params": { + "master_timeout": { + "type": "time", + "description": "Specify timeout for connection to master" + }, + "ignore_unavailable": { + "type": "boolean", + "description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type": "boolean", + "description": "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type": "enum", + "options": ["open", "closed"], + "default": "open", + "description": "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + } + } + }, + "body": { + "description": "The index settings to be updated", + "required": true + } + } +} diff --git a/rest-api-spec/api/indices.put_template.json b/rest-api-spec/api/indices.put_template.json new file mode 100644 index 0000000..f93dfd0 --- /dev/null +++ b/rest-api-spec/api/indices.put_template.json @@ -0,0 +1,39 @@ +{ + "indices.put_template": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-templates.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/_template/{name}", + "paths": ["/_template/{name}"], + "parts": { + "name": { + "type" : "string", + "required" : true, + "description" : "The name of the template" + } + }, + "params": { + "order": { + "type" : "number", + "description" : "The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + }, + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + } + } + }, + "body": { + "description" : "The template definition", + "required" : true + } + } +} diff --git a/rest-api-spec/api/indices.put_warmer.json b/rest-api-spec/api/indices.put_warmer.json new file mode 100644 index 0000000..03f97ef --- /dev/null +++ b/rest-api-spec/api/indices.put_warmer.json @@ -0,0 +1,49 @@ +{ + "indices.put_warmer": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-warmers.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/{index}/_warmer/{name}", + "paths": ["/_warmer/{name}", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}", "/_warmers/{name}", "/{index}/_warmers/{name}", "/{index}/{type}/_warmers/{name}"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to register the warmer for; use `_all` or omit to perform the operation on all indices" + }, + "name": { + "type" : "string", + "required" : true, + "description" : "The name of the warmer" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types to register the warmer for; leave empty to perform the operation on all types" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed) in the search request to warm" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices in the search request to warm. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both, in the search request to warm." + } + } + }, + "body": { + "description" : "The search request definition for the warmer (query, filters, facets, sorting, etc)", + "required" : true + } + } +} diff --git a/rest-api-spec/api/indices.refresh.json b/rest-api-spec/api/indices.refresh.json new file mode 100644 index 0000000..18e5ed2 --- /dev/null +++ b/rest-api-spec/api/indices.refresh.json @@ -0,0 +1,41 @@ +{ + "indices.refresh": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-refresh.html", + "methods": ["POST", "GET"], + "url": { + "path": "/_refresh", + "paths": ["/_refresh", "/{index}/_refresh"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "force": { + "type" : "boolean", + "description" : "Force a refresh even if not required", + "default": false + }, + "operation_threading": { + "description" : "TODO: ?" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.segments.json b/rest-api-spec/api/indices.segments.json new file mode 100644 index 0000000..77e3a18 --- /dev/null +++ b/rest-api-spec/api/indices.segments.json @@ -0,0 +1,41 @@ +{ + "indices.segments": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-segments.html", + "methods": ["GET"], + "url": { + "path": "/_segments", + "paths": ["/_segments", "/{index}/_segments"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "human": { + "type": "boolean", + "description": "Whether to return time and byte values in human-readable format.", + "default": false + }, + "operation_threading": { + "description" : "TODO: ?" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.snapshot_index.json b/rest-api-spec/api/indices.snapshot_index.json new file mode 100644 index 0000000..41cd7ba --- /dev/null +++ b/rest-api-spec/api/indices.snapshot_index.json @@ -0,0 +1,33 @@ +{ + "indices.snapshot_index": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/indices-gateway-snapshot.html", + "methods": ["POST"], + "url": { + "path": "/_gateway/snapshot", + "paths": ["/_gateway/snapshot", "/{index}/_gateway/snapshot"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string for all indices" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.stats.json b/rest-api-spec/api/indices.stats.json new file mode 100644 index 0000000..d4337e1 --- /dev/null +++ b/rest-api-spec/api/indices.stats.json @@ -0,0 +1,60 @@ +{ + "indices.stats": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-stats.html", + "methods": ["GET"], + "url": { + "path": "/_stats", + "paths": [ + "/_stats", + "/_stats/{metric}", + "/{index}/_stats", + "/{index}/_stats/{metric}" + ], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + }, + "metric" : { + "type" : "list", + "options" : ["_all", "completion", "docs", "fielddata", "filter_cache", "flush", "get", "id_cache", "indexing", "merge", "percolate", "refresh", "search", "segments", "store", "warmer"], + "description" : "Limit the information returned the specific metrics." + } + }, + "params": { + "completion_fields": { + "type" : "list", + "description" : "A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)" + }, + "fielddata_fields": { + "type" : "list", + "description" : "A comma-separated list of fields for `fielddata` index metric (supports wildcards)" + }, + "fields": { + "type" : "list", + "description" : "A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)" + }, + "groups": { + "type" : "boolean", + "description" : "A comma-separated list of search groups for `search` index metric" + }, + "human": { + "type": "boolean", + "description": "Whether to return time and byte values in human-readable format.", + "default": false + }, + "level": { + "type" : "enum", + "description": "Return stats aggregated at cluster, index or shard level", + "options" : ["cluster", "indices", "shards"], + "default" : "indices" + }, + "types" : { + "type" : "list", + "description" : "A comma-separated list of document types for the `indexing` index metric" + } + }, + "body": null + } + } +} diff --git a/rest-api-spec/api/indices.status.json b/rest-api-spec/api/indices.status.json new file mode 100644 index 0000000..177de04 --- /dev/null +++ b/rest-api-spec/api/indices.status.json @@ -0,0 +1,49 @@ +{ + "indices.status": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-status.html", + "methods": ["GET"], + "url": { + "path": "/_status", + "paths": ["/_status", "/{index}/_status"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "human": { + "type": "boolean", + "description": "Whether to return time and byte values in human-readable format.", + "default": false + }, + "operation_threading": { + "description" : "TODO: ?" + }, + "recovery": { + "type" : "boolean", + "description" : "Return information about shard recovery" + }, + "snapshot": { + "type" : "boolean", + "description" : "TODO: ?" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/indices.update_aliases.json b/rest-api-spec/api/indices.update_aliases.json new file mode 100644 index 0000000..5b375ee --- /dev/null +++ b/rest-api-spec/api/indices.update_aliases.json @@ -0,0 +1,26 @@ +{ + "indices.update_aliases": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/indices-aliases.html", + "methods": ["POST"], + "url": { + "path": "/_aliases", + "paths": ["/_aliases"], + "parts": { + }, + "params": { + "timeout": { + "type" : "time", + "description" : "Request timeout" + }, + "master_timeout": { + "type" : "time", + "description" : "Specify timeout for connection to master" + } + } + }, + "body": { + "description" : "The definition of `actions` to perform", + "required" : true + } + } +} diff --git a/rest-api-spec/api/indices.validate_query.json b/rest-api-spec/api/indices.validate_query.json new file mode 100644 index 0000000..324d648 --- /dev/null +++ b/rest-api-spec/api/indices.validate_query.json @@ -0,0 +1,54 @@ +{ + "indices.validate_query": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-validate.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_validate/query", + "paths": ["/_validate/query", "/{index}/_validate/query", "/{index}/{type}/_validate/query"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types" + } + }, + "params": { + "explain": { + "type" : "boolean", + "description" : "Return detailed information about the error" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "operation_threading": { + "description" : "TODO: ?" + }, + "source": { + "type" : "string", + "description" : "The URL-encoded query definition (instead of using the request body)" + }, + "q": { + "type" : "string", + "description" : "Query in the Lucene query string syntax" + } + } + }, + "body": { + "description" : "The query definition specified with the Query DSL" + } + } +} diff --git a/rest-api-spec/api/info.json b/rest-api-spec/api/info.json new file mode 100644 index 0000000..b83b666 --- /dev/null +++ b/rest-api-spec/api/info.json @@ -0,0 +1,15 @@ +{ + "info": { + "documentation": "http://www.elasticsearch.org/guide/", + "methods": ["GET"], + "url": { + "path": "/", + "paths": ["/"], + "parts": { + }, + "params": { + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/mget.json b/rest-api-spec/api/mget.json new file mode 100644 index 0000000..13688c7 --- /dev/null +++ b/rest-api-spec/api/mget.json @@ -0,0 +1,54 @@ +{ + "mget": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-multi-get.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_mget", + "paths": ["/_mget", "/{index}/_mget", "/{index}/{type}/_mget"], + "parts": { + "index": { + "type" : "string", + "description" : "The name of the index" + }, + "type": { + "type" : "string", + "description" : "The type of the document" + } + }, + "params": { + "fields": { + "type": "list", + "description" : "A comma-separated list of fields to return in the response" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "realtime": { + "type" : "boolean", + "description" : "Specify whether to perform the operation in realtime or search mode" + }, + "refresh": { + "type" : "boolean", + "description" : "Refresh the shard containing the document before performing the operation" + }, + "_source": { + "type" : "list", + "description" : "True or false to return the _source field or not, or a list of fields to return" + }, + "_source_exclude": { + "type" : "list", + "description" : "A list of fields to exclude from the returned _source field" + }, + "_source_include": { + "type" : "list", + "description" : "A list of fields to extract and return from the _source field" + } + } + }, + "body": { + "description" : "Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL.", + "required" : true + } + } +} diff --git a/rest-api-spec/api/mlt.json b/rest-api-spec/api/mlt.json new file mode 100644 index 0000000..911bd8f --- /dev/null +++ b/rest-api-spec/api/mlt.json @@ -0,0 +1,108 @@ +{ + "mlt": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-more-like-this.html", + "methods": ["GET", "POST"], + "url": { + "path": "/{index}/{type}/{id}/_mlt", + "paths": ["/{index}/{type}/{id}/_mlt"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "description" : "The document ID" + }, + "index": { + "type" : "string", + "required" : true, + "description" : "The name of the index" + }, + "type": { + "type" : "string", + "required" : true, + "description" : "The type of the document (use `_all` to fetch the first document matching the ID across all types)" + } + }, + "params": { + "boost_terms": { + "type" : "number", + "description" : "The boost factor" + }, + "max_doc_freq": { + "type" : "number", + "description" : "The word occurrence frequency as count: words with higher occurrence in the corpus will be ignored" + }, + "max_query_terms": { + "type" : "number", + "description" : "The maximum query terms to be included in the generated query" + }, + "max_word_length": { + "type" : "number", + "description" : "The minimum length of the word: longer words will be ignored" + }, + "min_doc_freq": { + "type" : "number", + "description" : "The word occurrence frequency as count: words with lower occurrence in the corpus will be ignored" + }, + "min_term_freq": { + "type" : "number", + "description" : "The term frequency as percent: terms with lower occurence in the source document will be ignored" + }, + "min_word_length": { + "type" : "number", + "description" : "The minimum length of the word: shorter words will be ignored" + }, + "mlt_fields": { + "type" : "list", + "description" : "Specific fields to perform the query against" + }, + "percent_terms_to_match": { + "type" : "number", + "description" : "How many terms have to match in order to consider the document a match (default: 0.3)" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "search_from": { + "type" : "number", + "description" : "The offset from which to return results" + }, + "search_indices": { + "type" : "list", + "description" : "A comma-separated list of indices to perform the query against (default: the index containing the document)" + }, + "search_query_hint": { + "type" : "string", + "description" : "The search query hint" + }, + "search_scroll": { + "type" : "string", + "description" : "A scroll search request definition" + }, + "search_size": { + "type" : "number", + "description" : "The number of documents to return (default: 10)" + }, + "search_source": { + "type" : "string", + "description" : "A specific search request definition (instead of using the request body)" + }, + "search_type": { + "type" : "string", + "description" : "Specific search type (eg. `dfs_then_fetch`, `count`, etc)" + }, + "search_types": { + "type" : "list", + "description" : "A comma-separated list of types to perform the query against (default: the same type as the document)" + }, + "stop_words": { + "type" : "list", + "description" : "A list of stop words to be ignored" + } + } + }, + "body": { + "description" : "A specific search request definition" + } + } +} diff --git a/rest-api-spec/api/mpercolate.json b/rest-api-spec/api/mpercolate.json new file mode 100644 index 0000000..4bf559a --- /dev/null +++ b/rest-api-spec/api/mpercolate.json @@ -0,0 +1,41 @@ +{ + "mpercolate": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-percolate.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_mpercolate", + "paths": ["/_mpercolate", "/{index}/_mpercolate", "/{index}/{type}/_mpercolate"], + "parts": { + "index": { + "type": "string", + "description": "The index of the document being count percolated to use as default" + }, + "type": { + "type" : "string", + "description" : "The type of the document being percolated to use as default." + } + }, + "params": { + "ignore_unavailable": { + "type": "boolean", + "description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type": "boolean", + "description": "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type": "enum", + "options": ["open", "closed"], + "default": "open", + "description": "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": { + "description": "The percolate request definitions (header & body pair), separated by newlines", + "required": true, + "serialize" : "bulk" + } + } +} diff --git a/rest-api-spec/api/msearch.json b/rest-api-spec/api/msearch.json new file mode 100644 index 0000000..97d8488 --- /dev/null +++ b/rest-api-spec/api/msearch.json @@ -0,0 +1,32 @@ +{ + "msearch": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-multi-search.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_msearch", + "paths": ["/_msearch", "/{index}/_msearch", "/{index}/{type}/_msearch"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to use as default" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types to use as default" + } + }, + "params": { + "search_type": { + "type" : "enum", + "options" : ["query_then_fetch", "query_and_fetch", "dfs_query_then_fetch", "dfs_query_and_fetch", "count", "scan"], + "description" : "Search operation type" + } + } + }, + "body": { + "description": "The request definitions (metadata-search request definition pairs), separated by newlines", + "required" : true, + "serialize" : "bulk" + } + } +} diff --git a/rest-api-spec/api/mtermvectors.json b/rest-api-spec/api/mtermvectors.json new file mode 100644 index 0000000..4697e74 --- /dev/null +++ b/rest-api-spec/api/mtermvectors.json @@ -0,0 +1,86 @@ +{ + "mtermvectors" : { + "documentation" : "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-multi-termvectors.html", + "methods" : ["GET", "POST"], + "url" : { + "path" : "/_mtermvectors", + "paths" : ["/_mtermvectors", "/{index}/_mtermvectors", "/{index}/{type}/_mtermvectors"], + "parts" : { + "index" : { + "type" : "string", + "description" : "The index in which the document resides." + }, + "type" : { + "type" : "string", + "description" : "The type of the document." + }, + "id" : { + "type" : "string", + "description" : "The id of the document." + } + }, + "params" : { + "ids" : { + "type" : "list", + "description" : "A comma-separated list of documents ids. You must define ids as parameter or set \"ids\" or \"docs\" in the request body", + "required" : false + }, + "term_statistics" : { + "type" : "boolean", + "description" : "Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "default" : false, + "required" : false + }, + "field_statistics" : { + "type" : "boolean", + "description" : "Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "default" : true, + "required" : false + }, + "fields" : { + "type" : "list", + "description" : "A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "required" : false + }, + "offsets" : { + "type" : "boolean", + "description" : "Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "default" : true, + "required" : false + }, + "positions" : { + "type" : "boolean", + "description" : "Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "default" : true, + "required" : false + }, + "payloads" : { + "type" : "boolean", + "description" : "Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "default" : true, + "required" : false + }, + "preference" : { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "required" : false + }, + "routing" : { + "type" : "string", + "description" : "Specific routing value. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "required" : false + }, + "parent" : { + "type" : "string", + "description" : "Parent id of documents. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".", + "required" : false + } + } + }, + "body" : { + "description" : "Define ids, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.", + "required" : false + + } + } +}
\ No newline at end of file diff --git a/rest-api-spec/api/nodes.hot_threads.json b/rest-api-spec/api/nodes.hot_threads.json new file mode 100644 index 0000000..64e4fe8 --- /dev/null +++ b/rest-api-spec/api/nodes.hot_threads.json @@ -0,0 +1,36 @@ +{ + "nodes.hot_threads": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-hot-threads.html", + "methods": ["GET"], + "url": { + "path": "/_nodes/hot_threads", + "paths": ["/_cluster/nodes/hotthreads", "/_cluster/nodes/hot_threads", "/_cluster/nodes/{node_id}/hotthreads", "/_cluster/nodes/{node_id}/hot_threads", "/_nodes/hotthreads", "/_nodes/hot_threads", "/_nodes/{node_id}/hotthreads", "/_nodes/{node_id}/hot_threads"], + "parts": { + "node_id": { + "type" : "list", + "description" : "A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes" + } + }, + "params": { + "interval": { + "type" : "time", + "description" : "The interval for the second sampling of threads" + }, + "snapshots": { + "type" : "number", + "description" : "Number of samples of thread stacktrace (default: 10)" + }, + "threads": { + "type" : "number", + "description" : "Specify the number of threads to provide information for (default: 3)" + }, + "type": { + "type" : "enum", + "options" : ["cpu", "wait", "block"], + "description" : "The type to sample (default: cpu)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/nodes.info.json b/rest-api-spec/api/nodes.info.json new file mode 100644 index 0000000..1e9bba8 --- /dev/null +++ b/rest-api-spec/api/nodes.info.json @@ -0,0 +1,33 @@ +{ + "nodes.info": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-info.html", + "methods": ["GET"], + "url": { + "path": "/_nodes", + "paths": ["/_nodes", "/_nodes/{node_id}", "/_nodes/{metric}", "/_nodes/{node_id}/{metric}"], + "parts": { + "node_id": { + "type": "list", + "description": "A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes" + }, + "metric": { + "type": "list", + "options": ["settings", "os", "process", "jvm", "thread_pool", "network", "transport", "http", "plugin"], + "description": "A comma-separated list of metrics you wish returned. Leave empty to return all." + } + }, + "params": { + "flat_settings": { + "type": "boolean", + "description": "Return settings in flat format (default: false)" + }, + "human": { + "type": "boolean", + "description": "Whether to return time and byte values in human-readable format.", + "default": false + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/nodes.shutdown.json b/rest-api-spec/api/nodes.shutdown.json new file mode 100644 index 0000000..578abe0 --- /dev/null +++ b/rest-api-spec/api/nodes.shutdown.json @@ -0,0 +1,27 @@ +{ + "nodes.shutdown": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-shutdown.html", + "methods": ["POST"], + "url": { + "path": "/_shutdown", + "paths": ["/_shutdown", "/_cluster/nodes/_shutdown", "/_cluster/nodes/{node_id}/_shutdown"], + "parts": { + "node_id": { + "type" : "list", + "description" : "A comma-separated list of node IDs or names to perform the operation on; use `_local` to perform the operation on the node you're connected to, leave empty to perform the operation on all nodes" + } + }, + "params": { + "delay": { + "type" : "time", + "description" : "Set the delay for the operation (default: 1s)" + }, + "exit": { + "type" : "boolean", + "description" : "Exit the JVM as well (default: true)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/nodes.stats.json b/rest-api-spec/api/nodes.stats.json new file mode 100644 index 0000000..3f81527 --- /dev/null +++ b/rest-api-spec/api/nodes.stats.json @@ -0,0 +1,67 @@ +{ + "nodes.stats": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/cluster-nodes-stats.html", + "methods": ["GET"], + "url": { + "path": "/_nodes/stats", + "paths": [ + "/_nodes/stats", + "/_nodes/{node_id}/stats", + "/_nodes/stats/{metric}", + "/_nodes/{node_id}/stats/{metric}", + "/_nodes/stats/{metric}/{index_metric}", + "/_nodes/{node_id}/stats/{metric}/{index_metric}" + ], + "parts": { + "metric" : { + "type" : "list", + "options" : ["_all", "breaker", "fs", "http", "indices", "jvm", "network", "os", "process", "thread_pool", "transport"], + "description" : "Limit the information returned to the specified metrics" + }, + "index_metric" : { + "type" : "list", + "options" : ["_all", "completion", "docs", "fielddata", "filter_cache", "flush", "get", "id_cache", "indexing", "merge", "percolate", "refresh", "search", "segments", "store", "warmer"], + "description" : "Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified." + }, + "node_id": { + "type" : "list", + "description" : "A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes" + } + }, + "params": { + "completion_fields": { + "type" : "list", + "description" : "A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)" + }, + "fielddata_fields": { + "type" : "list", + "description" : "A comma-separated list of fields for `fielddata` index metric (supports wildcards)" + }, + "fields": { + "type" : "list", + "description" : "A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)" + }, + "groups": { + "type" : "boolean", + "description" : "A comma-separated list of search groups for `search` index metric" + }, + "human": { + "type": "boolean", + "description": "Whether to return time and byte values in human-readable format.", + "default": false + }, + "level": { + "type" : "enum", + "description": "Return indices stats aggregated at node, index or shard level", + "options" : ["node", "indices", "shards"], + "default" : "node" + }, + "types" : { + "type" : "list", + "description" : "A comma-separated list of document types for the `indexing` index metric" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/percolate.json b/rest-api-spec/api/percolate.json new file mode 100644 index 0000000..50005a1 --- /dev/null +++ b/rest-api-spec/api/percolate.json @@ -0,0 +1,72 @@ +{ + "percolate": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-percolate.html", + "methods": ["GET", "POST"], + "url": { + "path": "/{index}/{type}/_percolate", + "paths": ["/{index}/{type}/_percolate", "/{index}/{type}/{id}/_percolate"], + "parts": { + "index": { + "type" : "string", + "required" : true, + "description" : "The index of the document being percolated." + }, + "type": { + "type" : "string", + "required" : true, + "description" : "The type of the document being percolated." + }, + "id": { + "type" : "string", + "required" : false, + "description" : "Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster." + } + }, + "params": { + "routing": { + "type" : "list", + "description" : "A comma-separated list of specific routing values" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "percolate_index": { + "type" : "string", + "description" : "The index to percolate the document into. Defaults to index." + }, + "percolate_type": { + "type" : "string", + "description" : "The type to percolate document into. Defaults to type." + }, + "version" : { + "type" : "number", + "description" : "Explicit version number for concurrency control" + }, + "version_type": { + "type" : "enum", + "options" : ["internal","external"], + "description" : "Specific version type" + } + } + }, + "body": { + "description" : "The percolator request definition using the percolate DSL", + "required" : false + } + } +} diff --git a/rest-api-spec/api/ping.json b/rest-api-spec/api/ping.json new file mode 100644 index 0000000..65e1856 --- /dev/null +++ b/rest-api-spec/api/ping.json @@ -0,0 +1,15 @@ +{ + "ping": { + "documentation": "http://www.elasticsearch.org/guide/", + "methods": ["HEAD"], + "url": { + "path": "/", + "paths": ["/"], + "parts": { + }, + "params": { + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/scroll.json b/rest-api-spec/api/scroll.json new file mode 100644 index 0000000..b01af64 --- /dev/null +++ b/rest-api-spec/api/scroll.json @@ -0,0 +1,29 @@ +{ + "scroll": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-scroll.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_search/scroll", + "paths": ["/_search/scroll", "/_search/scroll/{scroll_id}"], + "parts": { + "scroll_id": { + "type" : "string", + "description" : "The scroll ID" + } + }, + "params": { + "scroll": { + "type" : "duration", + "description" : "Specify how long a consistent view of the index should be maintained for scrolled search" + }, + "scroll_id": { + "type" : "string", + "description" : "The scroll ID for scrolled search" + } + } + }, + "body": { + "description": "The scroll ID if not passed by URL or query parameter." + } + } +} diff --git a/rest-api-spec/api/search.json b/rest-api-spec/api/search.json new file mode 100644 index 0000000..9c279bc --- /dev/null +++ b/rest-api-spec/api/search.json @@ -0,0 +1,156 @@ +{ + "search": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-search.html", + "methods": ["GET", "POST"], + "url": { + "path": "/_search", + "paths": ["/_search", "/{index}/_search", "/{index}/{type}/_search"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" + }, + "type": { + "type" : "list", + "description" : "A comma-separated list of document types to search; leave empty to perform the operation on all types" + } + }, + "params": { + "analyzer": { + "type" : "string", + "description" : "The analyzer to use for the query string" + }, + "analyze_wildcard": { + "type" : "boolean", + "description" : "Specify whether wildcard and prefix queries should be analyzed (default: false)" + }, + "default_operator": { + "type" : "enum", + "options" : ["AND","OR"], + "default" : "OR", + "description" : "The default operator for query string query (AND or OR)" + }, + "df": { + "type" : "string", + "description" : "The field to use as default where no field prefix is given in the query string" + }, + "explain": { + "type" : "boolean", + "description" : "Specify whether to return detailed information about score computation as part of a hit" + }, + "fields": { + "type" : "list", + "description" : "A comma-separated list of fields to return as part of a hit" + }, + "from": { + "type" : "number", + "description" : "Starting offset (default: 0)" + }, + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "indices_boost": { + "type" : "list", + "description" : "Comma-separated list of index boosts" + }, + "lenient": { + "type" : "boolean", + "description" : "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored" + }, + "lowercase_expanded_terms": { + "type" : "boolean", + "description" : "Specify whether query terms should be lowercased" + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "q": { + "type" : "string", + "description" : "Query in the Lucene query string syntax" + }, + "routing": { + "type" : "list", + "description" : "A comma-separated list of specific routing values" + }, + "scroll": { + "type" : "duration", + "description" : "Specify how long a consistent view of the index should be maintained for scrolled search" + }, + "search_type": { + "type" : "enum", + "options" : ["query_then_fetch", "query_and_fetch", "dfs_query_then_fetch", "dfs_query_and_fetch", "count", "scan"], + "description" : "Search operation type" + }, + "size": { + "type" : "number", + "description" : "Number of hits to return (default: 10)" + }, + "sort": { + "type" : "list", + "description" : "A comma-separated list of <field>:<direction> pairs" + }, + "source": { + "type" : "string", + "description" : "The URL-encoded request definition using the Query DSL (instead of using request body)" + }, + "_source": { + "type" : "list", + "description" : "True or false to return the _source field or not, or a list of fields to return" + }, + "_source_exclude": { + "type" : "list", + "description" : "A list of fields to exclude from the returned _source field" + }, + "_source_include": { + "type" : "list", + "description" : "A list of fields to extract and return from the _source field" + }, + "stats": { + "type" : "list", + "description" : "Specific 'tag' of the request for logging and statistical purposes" + }, + "suggest_field": { + "type" : "string", + "description" : "Specify which field to use for suggestions" + }, + "suggest_mode": { + "type" : "enum", + "options" : ["missing", "popular", "always"], + "default" : "missing", + "description" : "Specify suggest mode" + }, + "suggest_size": { + "type" : "number", + "description" : "How many suggestions to return in response" + }, + "suggest_text": { + "type" : "text", + "description" : "The source text for which the suggestions should be returned" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + }, + "version": { + "type" : "boolean", + "description" : "Specify whether to return document version as part of a hit" + } + } + }, + "body": { + "description": "The search definition using the Query DSL" + } + } +} diff --git a/rest-api-spec/api/snapshot.create.json b/rest-api-spec/api/snapshot.create.json new file mode 100644 index 0000000..b0608ab --- /dev/null +++ b/rest-api-spec/api/snapshot.create.json @@ -0,0 +1,37 @@ +{ + "snapshot.create": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/_snapshot/{repository}/{snapshot}", + "paths": ["/_snapshot/{repository}/{snapshot}", "/_snapshot/{repository}/{snapshot}/_create"], + "parts": { + "repository": { + "type": "string", + "required" : true, + "description": "A repository name" + }, + "snapshot": { + "type": "string", + "required" : true, + "description": "A snapshot name" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "wait_for_completion": { + "type": "boolean", + "description": "Should this request wait until the operation has completed before returning", + "default": false + } + } + }, + "body" : { + "description" : "The snapshot definition", + "required" : false + } + } +} diff --git a/rest-api-spec/api/snapshot.create_repository.json b/rest-api-spec/api/snapshot.create_repository.json new file mode 100644 index 0000000..2503546 --- /dev/null +++ b/rest-api-spec/api/snapshot.create_repository.json @@ -0,0 +1,31 @@ +{ + "snapshot.create_repository": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["PUT", "POST"], + "url": { + "path": "/_snapshot/{repository}", + "paths": ["/_snapshot/{repository}"], + "parts": { + "repository": { + "type": "string", + "required" : true, + "description": "A repository name" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": { + "description" : "The repository definition", + "required" : true + } + } +} diff --git a/rest-api-spec/api/snapshot.delete.json b/rest-api-spec/api/snapshot.delete.json new file mode 100644 index 0000000..de004b2 --- /dev/null +++ b/rest-api-spec/api/snapshot.delete.json @@ -0,0 +1,29 @@ +{ + "snapshot.delete": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["DELETE"], + "url": { + "path": "/_snapshot/{repository}/{snapshot}", + "paths": ["/_snapshot/{repository}/{snapshot}"], + "parts": { + "repository": { + "type": "string", + "required" : true, + "description": "A repository name" + }, + "snapshot": { + "type": "string", + "required" : true, + "description": "A snapshot name" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/snapshot.delete_repository.json b/rest-api-spec/api/snapshot.delete_repository.json new file mode 100644 index 0000000..d879c75 --- /dev/null +++ b/rest-api-spec/api/snapshot.delete_repository.json @@ -0,0 +1,28 @@ +{ + "snapshot.delete_repository": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["DELETE"], + "url": { + "path": "/_snapshot/{repository}", + "paths": ["/_snapshot/{repository}"], + "parts": { + "repository": { + "type": "list", + "required" : true, + "description": "A comma-separated list of repository names" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "timeout": { + "type" : "time", + "description" : "Explicit operation timeout" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/snapshot.get.json b/rest-api-spec/api/snapshot.get.json new file mode 100644 index 0000000..9639b92 --- /dev/null +++ b/rest-api-spec/api/snapshot.get.json @@ -0,0 +1,29 @@ +{ + "snapshot.get": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["GET"], + "url": { + "path": "/_snapshot/{repository}/{snapshot}", + "paths": ["/_snapshot/{repository}/{snapshot}"], + "parts": { + "repository": { + "type": "string", + "required" : true, + "description": "A repository name" + }, + "snapshot": { + "type": "list", + "required" : true, + "description": "A comma-separated list of snapshot names" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/snapshot.get_repository.json b/rest-api-spec/api/snapshot.get_repository.json new file mode 100644 index 0000000..567dce0 --- /dev/null +++ b/rest-api-spec/api/snapshot.get_repository.json @@ -0,0 +1,27 @@ +{ + "snapshot.get_repository": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["GET"], + "url": { + "path": "/_snapshot", + "paths": ["/_snapshot", "/_snapshot/{repository}"], + "parts": { + "repository": { + "type": "list", + "description": "A comma-separated list of repository names" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "local": { + "type": "boolean", + "description": "Return local information, do not retrieve the state from master node (default: false)" + } + } + }, + "body": null + } +} diff --git a/rest-api-spec/api/snapshot.restore.json b/rest-api-spec/api/snapshot.restore.json new file mode 100644 index 0000000..6c9da74 --- /dev/null +++ b/rest-api-spec/api/snapshot.restore.json @@ -0,0 +1,37 @@ +{ + "snapshot.restore": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/modules-snapshots.html", + "methods": ["POST"], + "url": { + "path": "/_snapshot/{repository}/{snapshot}/_restore", + "paths": ["/_snapshot/{repository}/{snapshot}/_restore"], + "parts": { + "repository": { + "type": "string", + "required" : true, + "description": "A repository name" + }, + "snapshot": { + "type": "string", + "required" : true, + "description": "A snapshot name" + } + }, + "params": { + "master_timeout": { + "type" : "time", + "description" : "Explicit operation timeout for connection to master node" + }, + "wait_for_completion": { + "type": "boolean", + "description": "Should this request wait until the operation has completed before returning", + "default": false + } + } + }, + "body" : { + "description" : "Details of what to restore", + "required" : false + } + } +} diff --git a/rest-api-spec/api/suggest.json b/rest-api-spec/api/suggest.json new file mode 100644 index 0000000..333b477 --- /dev/null +++ b/rest-api-spec/api/suggest.json @@ -0,0 +1,48 @@ +{ + "suggest": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-search.html", + "methods": ["POST", "GET"], + "url": { + "path": "/_suggest", + "paths": ["/_suggest", "/{index}/_suggest"], + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + }, + "preference": { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random)" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "source": { + "type" : "string", + "description" : "The URL-encoded request definition (instead of using request body)" + } + } + }, + "body": { + "description" : "The request definition", + "required" : true + } + } +} diff --git a/rest-api-spec/api/termvector.json b/rest-api-spec/api/termvector.json new file mode 100644 index 0000000..99a9bdf --- /dev/null +++ b/rest-api-spec/api/termvector.json @@ -0,0 +1,83 @@ +{ + "termvector" : { + "documentation" : "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-termvectors.html", + "methods" : ["GET", "POST"], + "url" : { + "path" : "/{index}/{type}/{id}/_termvector", + "paths" : ["/{index}/{type}/{id}/_termvector"], + "parts" : { + "index" : { + "type" : "string", + "description" : "The index in which the document resides.", + "required" : true + }, + "type" : { + "type" : "string", + "description" : "The type of the document.", + "required" : true + }, + "id" : { + "type" : "string", + "description" : "The id of the document.", + "required" : true + } + }, + "params": { + "term_statistics" : { + "type" : "boolean", + "description" : "Specifies if total term frequency and document frequency should be returned.", + "default" : false, + "required" : false + }, + "field_statistics" : { + "type" : "boolean", + "description" : "Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.", + "default" : true, + "required" : false + }, + "fields" : { + "type" : "list", + "description" : "A comma-separated list of fields to return.", + "required" : false + }, + "offsets" : { + "type" : "boolean", + "description" : "Specifies if term offsets should be returned.", + "default" : true, + "required" : false + }, + "positions" : { + "type" : "boolean", + "description" : "Specifies if term positions should be returned.", + "default" : true, + "required" : false + }, + "payloads" : { + "type" : "boolean", + "description" : "Specifies if term payloads should be returned.", + "default" : true, + "required" : false + }, + "preference" : { + "type" : "string", + "description" : "Specify the node or shard the operation should be performed on (default: random).", + "required" : false + }, + "routing" : { + "type" : "string", + "description" : "Specific routing value.", + "required" : false + }, + "parent": { + "type" : "string", + "description" : "Parent id of documents.", + "required" : false + } + } + }, + "body": { + "description" : "Define parameters. See documentation.", + "required" : false + } + } +} diff --git a/rest-api-spec/api/update.json b/rest-api-spec/api/update.json new file mode 100644 index 0000000..35a158f --- /dev/null +++ b/rest-api-spec/api/update.json @@ -0,0 +1,91 @@ +{ + "update": { + "documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-update.html", + "methods": ["POST"], + "url": { + "path": "/{index}/{type}/{id}/_update", + "paths": ["/{index}/{type}/{id}/_update"], + "parts": { + "id": { + "type" : "string", + "required" : true, + "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" + }, + "fields": { + "type": "list", + "description" : "A comma-separated list of fields to return in the response" + }, + "lang": { + "type" : "string", + "description" : "The script language (default: mvel)" + }, + "parent": { + "type" : "string", + "description" : "ID of the parent document" + }, + "refresh": { + "type" : "boolean", + "description" : "Refresh the index after performing the operation" + }, + "replication": { + "type" : "enum", + "options" : ["sync","async"], + "default" : "sync", + "description" : "Specific replication type" + }, + "retry_on_conflict": { + "type" : "number", + "description" : "Specify how many times should the operation be retried when a conflict occurs (default: 0)" + }, + "routing": { + "type" : "string", + "description" : "Specific routing value" + }, + "script": { + "description" : "The URL-encoded script definition (instead of using request body)" + }, + "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"], + "description" : "Specific version type" + } + } + }, + "body": { + "description" : "The request definition using either `script` or partial `doc`" + } + } +} diff --git a/rest-api-spec/test/README.asciidoc b/rest-api-spec/test/README.asciidoc new file mode 100644 index 0000000..97f7f09 --- /dev/null +++ b/rest-api-spec/test/README.asciidoc @@ -0,0 +1,233 @@ +Test Suite: +=========== + +A YAML test file consists of: +* an optional `setup` section, followed by +* one or more test sections + +For instance: + + setup: + - do: .... + - do: .... + + --- + "First test": + - do: ... + - match: ... + + --- + "Second test": + - do: ... + - match: ... + + +A `setup` section contains a list of commands to run before each test +section in order to setup the same environment for each test section. + +A test section represents an independent test, containing multiple `do` +statements and assertions. The contents of a test section must be run in +order, but individual test sections may be run in any order, as follows: + +1. run `setup` (if any) +2. reset the `response` var and the `stash` (see below) +2. run test contents +3. run teardown + +The `teardown` should delete all indices and all templates. + +Dot notation: +------------- +Dot notation is used for (1) method calls and (2) hierarchical data structures. For +instance, a method call like `cluster.health` would do the equivalent of: + + client.cluster.health(...params...) + +A test against `_tokens.1.token` would examine the `token` key, in the second element +of the `tokens` array, inside the `response` var (see below): + + $val = $response->{tokens}[1]{token} # Perl syntax roolz! + +If one of the levels (eg `tokens`) does not exist, it should return an undefined value. +If no field name is given (ie the empty string) then return the current +$val -- used for testing the whole response body. + +Use \. to specify paths that actually contain '.' in the key name, for example +in the `indices.get_settings` API. + +Skipping tests: +--------------- +If a test section should only be run on certain versions of Elasticsearch, +then the first entry in the section (after the title) should be called +`skip`, and should contain the range of versions to be +skipped, and the reason why the tests are skipped. For instance: + +.... + "Parent": + - skip: + version: "0 - 0.90.2" + reason: Delete ignores the parent param + + - do: + ... test definitions ... +.... + +All tests in the file following the skip statement should be skipped if: +`min <= current <= max`. + +The `version` range should always have an upper bound. Versions should +either have each version part compared numerically, or should be converted +to a string with sufficient digits to allow string comparison, eg + + 0.90.2 -> 000-090-002 + +Snapshot versions and versions of the form `1.0.0.Beta1` can be treated +as the rounded down version, eg `1.0.0`. + +The skip section can also be used to list new features that need to be +supported in order to run a test. This way the up-to-date runners will +run the test, while the ones that don't support the feature yet can +temporarily skip it, and avoid having lots of test failures in the meantime. +Once all runners have implemented the feature, it can be declared supported +by default, thus the related skip sections can be removed from the tests. + +.... + "Parent": + - skip: + features: regex + + - do: + ... test definitions ... +.... + +The `features` field can either be a string or an array of strings. +The skip section requires to specify either a `version` or a `features` list. + +Required operators: +------------------- + +=== `do` + +The `do` operator calls a method on the client. For instance: + +.... + - do: + cluster.health: + level: shards +.... + +The response from the `do` operator should be stored in the `response` var, which +is reset (1) at the beginning of a file or (2) on the next `do`. + +If the arguments to `do` include `catch`, then we are expecting an error, which should +be caught and tested. For instance: + +.... + - do: + catch: missing + get: + index: test + type: test + id: 1 +.... + +The argument to `catch` can be any of: + +[horizontal] +`missing`:: a 404 response from ES +`conflict`:: a 409 response from ES +`request`:: a generic error response from ES +`param`:: a client-side error indicating an unknown parameter has been passed + to the method +`/foo bar/`:: the text of the error message matches this regular expression + +If `catch` is specified, then the `response` var must be cleared, and the test +should fail if no error is thrown. + +=== `set` + +For some tests, it is necessary to extract a value from the previous `response`, in +order to reuse it in a subsequent `do` and other tests. For instance, when +testing indexing a document without a specified ID: + +.... + - do: + index: + index: test + type: test + - set: { _id: id } # stash the value of `response._id` as `id` + - do: + get: + index: test + type: test + id: $id # replace `$id` with the stashed value + - match: { _id: $id } # the returned `response._id` matches the stashed `id` +.... + +The last response obtained gets always stashed automatically as a string, called `body`. +This is useful when needing to test apis that return text rather than json (e.g. cat api), +as it allows to treat the whole body as an ordinary string field. + +Note that not only expected values can be retrieved from the stashed values (as in the +example above), but the same goes for actual values: + +.... + - match: { $body: /^.+$/ } # the returned `body` matches the provided regex +.... + +The stash should be reset at the beginning of each test file. + +=== `is_true` + +The specified key exists and has a true value (ie not `0`, `false`, `undefined`, `null` +or the empty string), eg: + +.... + - is_true: fields._parent # the _parent key exists in the fields hash and is "true" +.... + +=== `is_false` + +The specified key doesn't exist or has a false value (ie `0`, `false`, `undefined`, +`null` or the empty string), eg: + +.... + - is_false: fields._source # the _source key doesn't exist in the fields hash or is "false" +.... + +=== `match` + +Used to compare two variables (could be scalars, arrays or hashes). The two variables +should be identical, eg: + +.... + - match: { _source: { foo: bar }} +.... + +Supports also regular expressions with flag X for more readability (accepts whitespaces and comments): + +.... + - match: + $body: > + /^ epoch \s+ timestamp \s+ count \s+ \n + \d+ \s+ \d{2}:\d{2}:\d{2} \s+ \d+ \s+ \n $/ +.... + +=== `lt` and `gt` + +Compares two numeric values, eg: + +.... + - lt: { fields._ttl: 10000 } # the `_ttl` value is less than 10,000 +.... + +=== `length` + +This depends on the datatype of the value being examined, eg: + +.... + - length: { _id: 22 } # the `_id` string is 22 chars long + - length: { _tokens: 3 } # the `_tokens` array has 3 elements + - length: { _source: 5 } # the `_source` hash has 5 keys +.... + diff --git a/rest-api-spec/test/bulk/10_basic.yaml b/rest-api-spec/test/bulk/10_basic.yaml new file mode 100644 index 0000000..f861711 --- /dev/null +++ b/rest-api-spec/test/bulk/10_basic.yaml @@ -0,0 +1,25 @@ +--- +"Array of objects": + - do: + bulk: + refresh: true + body: + - index: + _index: test_index + _type: test_type + _id: test_id + - f1: v1 + f2: 42 + - index: + _index: test_index + _type: test_type + _id: test_id2 + - f1: v2 + f2: 47 + + - do: + count: + index: test_index + + - match: {count: 2} + diff --git a/rest-api-spec/test/bulk/20_list_of_strings.yaml b/rest-api-spec/test/bulk/20_list_of_strings.yaml new file mode 100644 index 0000000..def91f4 --- /dev/null +++ b/rest-api-spec/test/bulk/20_list_of_strings.yaml @@ -0,0 +1,17 @@ +--- +"List of strings": + - do: + bulk: + refresh: true + body: + - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}}' + - '{"f1": "v1", "f2": 42}' + - '{"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}}' + - '{"f1": "v2", "f2": 47}' + + - do: + count: + index: test_index + + - match: {count: 2} + diff --git a/rest-api-spec/test/bulk/30_big_string.yaml b/rest-api-spec/test/bulk/30_big_string.yaml new file mode 100644 index 0000000..1d11725 --- /dev/null +++ b/rest-api-spec/test/bulk/30_big_string.yaml @@ -0,0 +1,17 @@ +--- +"One big string": + - do: + bulk: + refresh: true + body: | + {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id"}} + {"f1": "v1", "f2": 42} + {"index": {"_index": "test_index", "_type": "test_type", "_id": "test_id2"}} + {"f1": "v2", "f2": 47} + + - do: + count: + index: test_index + + - match: {count: 2} + diff --git a/rest-api-spec/test/cat.aliases/10_basic.yaml b/rest-api-spec/test/cat.aliases/10_basic.yaml new file mode 100644 index 0000000..dc3d0f9 --- /dev/null +++ b/rest-api-spec/test/cat.aliases/10_basic.yaml @@ -0,0 +1,190 @@ +--- +"Help": + - do: + cat.aliases: + help: true + + - match: + $body: > + /^ alias .+ \n + index .+ \n + filter .+ \n + routing.index .+ \n + routing.search .+ \n + $/ + +--- +"Empty cluster": + + - do: + cat.aliases: {} + + - match: + $body: > + /^ + $/ + +--- +"Simple alias": + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_alias + + - do: + cat.aliases: {} + + - match: + $body: > + /^ + test_alias \s+ + test \s+ + - \s+ + - \s+ + - \s+ + $/ + +--- +"Complex alias": + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_alias + body: + index_routing: ir + search_routing: "sr1,sr2" + filter: + term: + foo: bar + - do: + cat.aliases: {} + + - match: + $body: > + /^ + test_alias \s+ + test \s+ + [*] \s+ + ir \s+ + sr1,sr2 \s+ + $/ + +--- +"Alias name": + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_1 + + - do: + indices.put_alias: + index: test + name: test_2 + + - do: + cat.aliases: + name: test_1 + + - match: + $body: /^test_1 .+ \n$/ + + - do: + cat.aliases: + name: test_2 + + - match: + $body: /^test_2 .+ \n$/ + + - do: + cat.aliases: + name: test_* + + - match: + $body: / (^|\n)test_1 .+ \n/ + + - match: + $body: / (^|\n)test_2 .+ \n/ + +--- +"Column headers": + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_1 + + - do: + cat.aliases: + v: true + + - match: + $body: > + /^ alias \s+ + index \s+ + filter \s+ + routing.index \s+ + routing.search \s+ + \n + test_1 \s+ + test \s+ + - \s+ + - \s+ + - \s+ + $/ + + +--- +"Select columns": + + - do: + indices.create: + index: test + + - do: + indices.put_alias: + index: test + name: test_1 + + - do: + cat.aliases: + h: [index, alias] + + - match: + $body: /^ test \s+ test_1 \s+ $/ + + + - do: + cat.aliases: + h: [index, alias] + v: true + - match: + $body: > + /^ + index \s+ alias \s+ \n + test \s+ test_1 \s+ \n + $/ + + + + + + diff --git a/rest-api-spec/test/cat.allocation/10_basic.yaml b/rest-api-spec/test/cat.allocation/10_basic.yaml new file mode 100644 index 0000000..6250e42 --- /dev/null +++ b/rest-api-spec/test/cat.allocation/10_basic.yaml @@ -0,0 +1,194 @@ +--- +"Help": + - do: + cat.allocation: + help: true + + - match: + $body: > + /^ shards .+ \n + disk.used .+ \n + disk.avail .+ \n + disk.total .+ \n + disk.percent .+ \n + host .+ \n + ip .+ \n + node .+ \n + $/ + +--- +"Empty cluster": + + - do: + cat.allocation: {} + + - match: + $body: > + /^ + ( 0 \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+ \s+ + [-\w.]+ \s+ + \d+(\.\d+){3} \s+ + \w.* + \n + )+ + $/ + +--- +"One index": + + - do: + indices.create: + index: test + + - do: + cluster.health: + wait_for_status: green + timeout: 1s + + - do: + cat.allocation: {} + + - match: + $body: > + /^ + ( [1-5] \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+ \s+ + [-\w.]+ \s+ + \d+(\.\d+){3} \s+ + \w.* + \n + )+ + ( + \d+ \s+ + UNASSIGNED \s+ + \n + )? + $/ + +--- +"Node ID": + + - do: + cat.allocation: + node_id: _master + + - match: + $body: > + /^ + ( 0 \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+ \s+ + [-\w.]+ \s+ + \d+(\.\d+){3} \s+ + \w.* + \n + ) + $/ + + - do: + cat.allocation: + node_id: non_existent + + - match: + $body: > + /^ + $/ + +--- +"Column headers": + + - do: + cat.allocation: + v: true + - match: + + $body: > + /^ shards \s+ + disk.used \s+ + disk.avail \s+ + disk.total \s+ + disk.percent \s+ + host \s+ + ip \s+ + node \s+ + \n + + ( \s+0 \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+(\.\d+)?[kmgt]b \s+ + \d+ \s+ + [-\w.]+ \s+ + \d+(\.\d+){3} \s+ + \w.* + \n + )+ + $/ + +--- +"Select columns": + + - do: + cat.allocation: + h: [disk.percent, node] + + - match: + $body: > + /^ + ( \d+ \s+ + \w.* + \n + )+ + $/ + + - do: + cat.allocation: + h: [disk.percent, node] + v: true + + - match: + $body: > + /^ + disk.percent \s+ + node \s+ + \n + ( + \s+\d+ \s+ + \w.* + \n + )+ + $/ + + +--- + +"Bytes": + + - do: + cat.allocation: + bytes: g + + - match: + $body: > + /^ + ( 0 \s+ + \d+ \s+ + \d+ \s+ + \d+ \s+ + \d+ \s+ + [-\w.]+ \s+ + \d+(\.\d+){3} \s+ + \w.* + \n + )+ + $/ + diff --git a/rest-api-spec/test/cat.count/10_basic.yaml b/rest-api-spec/test/cat.count/10_basic.yaml new file mode 100644 index 0000000..d918652 --- /dev/null +++ b/rest-api-spec/test/cat.count/10_basic.yaml @@ -0,0 +1,76 @@ +--- +"Test cat count help": + - do: + cat.count: + help: true + + - match: + $body: > + /^ epoch .+ \n + timestamp .+ \n + count .+ \n $/ + +--- +"Test cat count output": + + - do: + cat.count: {} + + - match: + $body: > + /# epoch timestamp count + ^ \d+ \s \d{2}:\d{2}:\d{2} \s 0 \s $/ + + - do: + index: + index: index1 + type: type1 + id: 1 + body: { foo: bar } + refresh: true + + - do: + cat.count: {} + + - match: + $body: > + /# epoch timestamp count + ^ \d+ \s \d{2}:\d{2}:\d{2} \s 1 \s $/ + + - do: + index: + index: index2 + type: type2 + id: 1 + body: { foo: bar } + refresh: true + + - do: + cat.count: + h: count + + - match: + $body: > + /# count + ^ 2 \s $/ + + + - do: + cat.count: + index: index1 + + - match: + $body: > + /# epoch timestamp count + ^ \d+ \s \d{2}:\d{2}:\d{2} \s 1 \s $/ + + - do: + cat.count: + index: index2 + v: true + + - match: + $body: > + /^ epoch \s+ timestamp \s+ count \s+ \n + \d+ \s+ \d{2}:\d{2}:\d{2} \s+ \d+ \s+ \n $/ + diff --git a/rest-api-spec/test/cat.shards/10_basic.yaml b/rest-api-spec/test/cat.shards/10_basic.yaml new file mode 100644 index 0000000..223fdc2 --- /dev/null +++ b/rest-api-spec/test/cat.shards/10_basic.yaml @@ -0,0 +1,49 @@ +--- +"Test cat shards output": + + - do: + cat.shards: {} + + - match: + $body: > + /^$/ + + - do: + index: + index: index1 + type: type1 + id: 1 + body: { foo: bar } + refresh: true + - do: + cluster.health: + wait_for_status: yellow + - do: + cat.shards: {} + + - match: + $body: > + /^(index1 \s+ \d \s+ (p|r) \s+ ((STARTED|INITIALIZING) \s+ (\d \s+ (\d+|\d+[.]\d+)(kb|b) \s+)? \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} \s+ .+|UNASSIGNED \s+) \n?){10}$/ + + - do: + indices.create: + index: index2 + body: + settings: + number_of_replicas: "0" + - do: + cluster.health: + wait_for_status: yellow + + - do: + cat.shards: {} + - match: + $body: > + /^(index(1|2) \s+ \d \s+ (p|r) \s+ ((STARTED|INITIALIZING) \s+ (\d \s+ (\d+|\d+[.]\d+)(kb|b) \s+)? \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} \s+ .+|UNASSIGNED \s+) \n?){15}$/ + + - do: + cat.shards: + index: index2 + - match: + $body: > + /^(index2 \s+ \d \s+ (p|r) \s+ ((STARTED|INITIALIZING) \s+ (\d \s+ (\d+|\d+[.]\d+)(kb|b) \s+)? \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} \s+ .+|UNASSIGNED \s+) \n?){5}$/ diff --git a/rest-api-spec/test/cat.thread_pool/10_basic.yaml b/rest-api-spec/test/cat.thread_pool/10_basic.yaml new file mode 100644 index 0000000..af59d28 --- /dev/null +++ b/rest-api-spec/test/cat.thread_pool/10_basic.yaml @@ -0,0 +1,40 @@ +--- +"Test cat thread_pool output": + + - do: + cat.thread_pool: {} + + - match: + $body: > + / #host ip bulk.active bulk.queue bulk.rejected index.active index.queue index.rejected search.active search.queue search.rejected + ^ (\S+ \s+ (\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \n)+ $/ + + - do: + cat.thread_pool: + v: true + + - match: + $body: > + /^ host \s+ ip \s+ bulk.active \s+ bulk.queue \s+ bulk.rejected \s+ index.active \s+ index.queue \s+ index.rejected \s+ search.active \s+ search.queue \s+ search.rejected \s+ \n + (\S+ \s+ (\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \n)+ $/ + + - do: + cat.thread_pool: + h: pid,id,h,i,po + + - match: + $body: > + / #pid id host ip port + ^ (\d+ \s+ \S{4} \s+ \S+ \s+ (\d{1,3}\.){3}\d{1,3} \s+ \d{4} \n)+ $/ + + - do: + cat.thread_pool: + h: id,ba,fa,gea,ga,ia,maa,ma,oa,pa + v: true + full_id: true + + - match: + $body: > + /^ id \s+ ba \s+ fa \s+ gea \s+ ga \s+ ia \s+ maa \s+ ma \s+ oa \s+ pa \s+ \n + (\S+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d+ \s+ \n)+ $/ + diff --git a/rest-api-spec/test/cluster.pending_tasks/10_basic.yaml b/rest-api-spec/test/cluster.pending_tasks/10_basic.yaml new file mode 100644 index 0000000..f8fd8eb --- /dev/null +++ b/rest-api-spec/test/cluster.pending_tasks/10_basic.yaml @@ -0,0 +1,14 @@ +--- +"Test pending tasks": + - do: + cluster.pending_tasks: {} + + - is_true: tasks +--- +"Test pending tasks with local flag": + - do: + cluster.pending_tasks: + local: true + + - is_true: tasks + diff --git a/rest-api-spec/test/cluster.put_settings/10_basic.yaml b/rest-api-spec/test/cluster.put_settings/10_basic.yaml new file mode 100644 index 0000000..e80ab74 --- /dev/null +++ b/rest-api-spec/test/cluster.put_settings/10_basic.yaml @@ -0,0 +1,16 @@ +--- +"Test put settings": + - do: + cluster.put_settings: + body: + transient: + discovery.zen.minimum_master_nodes: 1 + flat_settings: true + + - match: {transient: {discovery.zen.minimum_master_nodes: "1"}} + + - do: + cluster.get_settings: + flat_settings: true + + - match: {transient: {discovery.zen.minimum_master_nodes: "1"}} diff --git a/rest-api-spec/test/cluster.reroute/10_basic.yaml b/rest-api-spec/test/cluster.reroute/10_basic.yaml new file mode 100644 index 0000000..771f647 --- /dev/null +++ b/rest-api-spec/test/cluster.reroute/10_basic.yaml @@ -0,0 +1,4 @@ +--- +"Basic sanity check": + - do: + cluster.reroute: {} diff --git a/rest-api-spec/test/cluster.state/10_basic.yaml b/rest-api-spec/test/cluster.state/10_basic.yaml new file mode 100644 index 0000000..1bea4ad --- /dev/null +++ b/rest-api-spec/test/cluster.state/10_basic.yaml @@ -0,0 +1,6 @@ +--- +"cluster state test": + - do: + cluster.state: {} + + - is_true: master_node diff --git a/rest-api-spec/test/cluster.state/20_filtering.yaml b/rest-api-spec/test/cluster.state/20_filtering.yaml new file mode 100644 index 0000000..7c77ea5 --- /dev/null +++ b/rest-api-spec/test/cluster.state/20_filtering.yaml @@ -0,0 +1,164 @@ +setup: + - do: + index: + index: testidx + type: testtype + id: testing_document + body: + "text" : "The quick brown fox is brown." + - do: + indices.refresh: {} + +--- +"Filtering the cluster state by blocks should return the blocks field even if the response is empty": + - do: + cluster.state: + metric: [ blocks ] + + - is_true: blocks + - is_false: nodes + - is_false: metadata + - is_false: routing_table + - is_false: routing_nodes + - is_false: allocations + - length: { blocks: 0 } + +--- +"Filtering the cluster state by blocks should return the blocks": +# read only index +# TODO: can this cause issues leaving it read only when deleting it in teardown + - do: + indices.put_settings: + index: testidx + body: + index.blocks.read_only: true + - do: + cluster.state: + metric: [ blocks ] + + - is_true: blocks + - is_false: nodes + - is_false: metadata + - is_false: routing_table + - is_false: routing_nodes + - is_false: allocations + - length: { blocks: 1 } + +--- +"Filtering the cluster state by nodes only should work": + - do: + cluster.state: + metric: [ nodes ] + + - is_false: blocks + - is_true: nodes + - is_false: metadata + - is_false: routing_table + - is_false: routing_nodes + - is_false: allocations + +--- +"Filtering the cluster state by metadata only should work": + - do: + cluster.state: + metric: [ metadata ] + + - is_false: blocks + - is_false: nodes + - is_true: metadata + - is_false: routing_table + - is_false: routing_nodes + - is_false: allocations + + +--- +"Filtering the cluster state by routing table only should work": + - do: + cluster.state: + metric: [ routing_table ] + + - is_false: blocks + - is_false: nodes + - is_false: metadata + - is_true: routing_table + - is_true: routing_nodes + - is_true: allocations + + +--- +"Filtering the cluster state for specific index templates should work ": + - do: + indices.put_template: + name: test1 + body: + template: test-* + settings: + number_of_shards: 1 + + - do: + indices.put_template: + name: test2 + body: + template: test-* + settings: + number_of_shards: 2 + + - do: + indices.put_template: + name: foo + body: + template: foo-* + settings: + number_of_shards: 3 + - do: + cluster.state: + metric: [ metadata ] + index_templates: [ test1, test2 ] + + - is_false: blocks + - is_false: nodes + - is_true: metadata + - is_false: routing_table + - is_false: routing_nodes + - is_false: allocations + - is_true: metadata.templates.test1 + - is_true: metadata.templates.test2 + - is_false: metadata.templates.foo + +--- +"Filtering the cluster state by indices should work in routing table and metadata": + - do: + index: + index: another + type: type + id: testing_document + body: + "text" : "The quick brown fox is brown." + + - do: + indices.refresh: {} + + - do: + cluster.state: + metric: [ routing_table, metadata ] + index: [ testidx ] + + - is_false: metadata.indices.another + - is_false: routing_table.indices.another + - is_true: metadata.indices.testidx + - is_true: routing_table.indices.testidx + +--- +"Filtering the cluster state using _all for indices and metrics should work": + - do: + cluster.state: + metric: [ '_all' ] + index: [ '_all' ] + + - is_true: blocks + - is_true: nodes + - is_true: metadata + - is_true: routing_table + - is_true: routing_nodes + - is_true: allocations + diff --git a/rest-api-spec/test/create/10_with_id.yaml b/rest-api-spec/test/create/10_with_id.yaml new file mode 100644 index 0000000..1e58c38 --- /dev/null +++ b/rest-api-spec/test/create/10_with_id.yaml @@ -0,0 +1,33 @@ +--- +"Create with ID": + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1"} + - match: { _version: 1} + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1"} + - match: { _version: 1} + - match: { _source: { foo: bar }} + + - do: + catch: conflict + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } diff --git a/rest-api-spec/test/create/15_without_id.yaml b/rest-api-spec/test/create/15_without_id.yaml new file mode 100644 index 0000000..0342fdb --- /dev/null +++ b/rest-api-spec/test/create/15_without_id.yaml @@ -0,0 +1,25 @@ +--- +"Create without ID": + - do: + create: + index: test_1 + type: test + body: { foo: bar } + + - is_true: _id + - match: { _index: test_1 } + - match: { _type: test } + - match: { _version: 1 } + - set: { _id: id } + + - do: + get: + index: test_1 + type: test + id: '$id' + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: $id } + - match: { _version: 1 } + - match: { _source: { foo: bar }} diff --git a/rest-api-spec/test/create/30_internal_version.yaml b/rest-api-spec/test/create/30_internal_version.yaml new file mode 100644 index 0000000..fcdb233 --- /dev/null +++ b/rest-api-spec/test/create/30_internal_version.yaml @@ -0,0 +1,20 @@ +--- +"Internal version": + + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - match: { _version: 1} + + - do: + catch: conflict + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + diff --git a/rest-api-spec/test/create/35_external_version.yaml b/rest-api-spec/test/create/35_external_version.yaml new file mode 100644 index 0000000..8ee11b0 --- /dev/null +++ b/rest-api-spec/test/create/35_external_version.yaml @@ -0,0 +1,33 @@ +--- +"External version": + + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - match: { _version: 5} + + - do: + catch: conflict + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - do: + catch: conflict + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 6 diff --git a/rest-api-spec/test/create/40_routing.yaml b/rest-api-spec/test/create/40_routing.yaml new file mode 100644 index 0000000..bc3fb84 --- /dev/null +++ b/rest-api-spec/test/create/40_routing.yaml @@ -0,0 +1,41 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + create: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + fields: [_routing] + + - match: { _id: "1"} + - match: { fields._routing: "5"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/create/50_parent.yaml b/rest-api-spec/test/create/50_parent.yaml new file mode 100644 index 0000000..dcd24d9 --- /dev/null +++ b/rest-api-spec/test/create/50_parent.yaml @@ -0,0 +1,43 @@ +--- +"Parent": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + + - do: + cluster.health: + wait_for_status: yellow + + - do: + catch: /RoutingMissingException/ + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + create: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + fields: [_parent, _routing] + + - match: { _id: "1"} + - match: { fields._parent: "5"} + - match: { fields._routing: "5"} + diff --git a/rest-api-spec/test/create/55_parent_with_routing.yaml b/rest-api-spec/test/create/55_parent_with_routing.yaml new file mode 100644 index 0000000..ec94718 --- /dev/null +++ b/rest-api-spec/test/create/55_parent_with_routing.yaml @@ -0,0 +1,54 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + create: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + fields: [_parent, _routing] + + - match: { _id: "1"} + - match: { fields._parent: "5"} + - match: { fields._routing: "4"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + parent: 5 + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 4 + diff --git a/rest-api-spec/test/create/60_refresh.yaml b/rest-api-spec/test/create/60_refresh.yaml new file mode 100644 index 0000000..99bfbc3 --- /dev/null +++ b/rest-api-spec/test/create/60_refresh.yaml @@ -0,0 +1,46 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index.refresh_interval: -1 + number_of_replicas: 0 + - do: + cluster.health: + wait_for_status: yellow + + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + search: + index: test_1 + type: test + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 0 } + + - do: + create: + index: test_1 + type: test + id: 2 + refresh: 1 + body: { foo: bar } + + - do: + search: + index: test_1 + type: test + body: + query: { term: { _id: 2 }} + + - match: { hits.total: 1 } diff --git a/rest-api-spec/test/create/70_timestamp.yaml b/rest-api-spec/test/create/70_timestamp.yaml new file mode 100644 index 0000000..f48a9fa --- /dev/null +++ b/rest-api-spec/test/create/70_timestamp.yaml @@ -0,0 +1,81 @@ +--- +"Timestamp": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _timestamp: + enabled: 1 + store: yes + - do: + cluster.health: + wait_for_status: yellow + +# blank timestamp + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - is_true: fields._timestamp + +# milliseconds since epoch + + - do: + delete: + index: test_1 + type: test + id: 1 + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + timestamp: 1372011280000 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - match: { fields._timestamp: 1372011280000 } + +# date format + + - do: + delete: + index: test_1 + type: test + id: 1 + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + timestamp: 2013-06-23T18:14:40 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - match: { fields._timestamp: 1372011280000 } + diff --git a/rest-api-spec/test/create/75_ttl.yaml b/rest-api-spec/test/create/75_ttl.yaml new file mode 100644 index 0000000..05eb88e --- /dev/null +++ b/rest-api-spec/test/create/75_ttl.yaml @@ -0,0 +1,104 @@ +--- +"TTL": + + - skip: + features: gtelte + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _ttl: + enabled: 1 + store: yes + default: 10s + - do: + cluster.health: + wait_for_status: yellow + +# blank ttl + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 10000} + - gt: { fields._ttl: 0} + +# milliseconds + + - do: + delete: + index: test_1 + type: test + id: 1 + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 100000 + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 100000} + - gt: { fields._ttl: 10000} + +# duration + + - do: + delete: + index: test_1 + type: test + id: 1 + - do: + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 20s + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 20000} + - gt: { fields._ttl: 10000} + +# with timestamp + + - do: + delete: + index: test_1 + type: test + id: 1 + - do: + catch: /AlreadyExpiredException/ + create: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 20s + timestamp: 2013-06-23T18:14:40 + diff --git a/rest-api-spec/test/create/TODO.txt b/rest-api-spec/test/create/TODO.txt new file mode 100644 index 0000000..d8a93ca --- /dev/null +++ b/rest-api-spec/test/create/TODO.txt @@ -0,0 +1,5 @@ +Tests missing for: + +# consistency +# percolate +# replication diff --git a/rest-api-spec/test/delete/10_basic.yaml b/rest-api-spec/test/delete/10_basic.yaml new file mode 100644 index 0000000..a3671d5 --- /dev/null +++ b/rest-api-spec/test/delete/10_basic.yaml @@ -0,0 +1,19 @@ +--- +"Basic": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - match: { _version: 1 } + + - do: + delete: + index: test_1 + type: test + id: 1 + + - match: { _version: 2 } diff --git a/rest-api-spec/test/delete/20_internal_version.yaml b/rest-api-spec/test/delete/20_internal_version.yaml new file mode 100644 index 0000000..3d9ddb7 --- /dev/null +++ b/rest-api-spec/test/delete/20_internal_version.yaml @@ -0,0 +1,28 @@ +--- +"Internal version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - match: { _version: 1} + + - do: + catch: conflict + delete: + index: test_1 + type: test + id: 1 + version: 2 + + - do: + delete: + index: test_1 + type: test + id: 1 + version: 1 + + - match: { _version: 2 } diff --git a/rest-api-spec/test/delete/25_external_version.yaml b/rest-api-spec/test/delete/25_external_version.yaml new file mode 100644 index 0000000..453d64d --- /dev/null +++ b/rest-api-spec/test/delete/25_external_version.yaml @@ -0,0 +1,32 @@ +--- +"External version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - match: { _version: 5} + + - do: + catch: conflict + delete: + index: test_1 + type: test + id: 1 + version_type: external + version: 4 + + - do: + delete: + index: test_1 + type: test + id: 1 + version_type: external + version: 6 + + - match: { _version: 6} diff --git a/rest-api-spec/test/delete/30_routing.yaml b/rest-api-spec/test/delete/30_routing.yaml new file mode 100644 index 0000000..b0d3ca3 --- /dev/null +++ b/rest-api-spec/test/delete/30_routing.yaml @@ -0,0 +1,29 @@ +--- +"Routing": + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + - do: + cluster.health: + wait_for_status: yellow + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + routing: 4 + + - do: + delete: + index: test_1 + type: test + id: 1 + routing: 5 + diff --git a/rest-api-spec/test/delete/40_parent.yaml b/rest-api-spec/test/delete/40_parent.yaml new file mode 100644 index 0000000..6e8beca --- /dev/null +++ b/rest-api-spec/test/delete/40_parent.yaml @@ -0,0 +1,36 @@ +--- +"Parent": + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + parent: 1 + + - do: + delete: + index: test_1 + type: test + id: 1 + parent: 5 + diff --git a/rest-api-spec/test/delete/42_missing_parent.yml b/rest-api-spec/test/delete/42_missing_parent.yml new file mode 100644 index 0000000..ac00a8d --- /dev/null +++ b/rest-api-spec/test/delete/42_missing_parent.yml @@ -0,0 +1,28 @@ +--- +"Delete on all shards when parent not specified": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + - do: + delete: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/delete/45_parent_with_routing.yaml b/rest-api-spec/test/delete/45_parent_with_routing.yaml new file mode 100644 index 0000000..7a11db4 --- /dev/null +++ b/rest-api-spec/test/delete/45_parent_with_routing.yaml @@ -0,0 +1,43 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: { foo: bar } + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 1 + + - do: + delete: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + diff --git a/rest-api-spec/test/delete/50_refresh.yaml b/rest-api-spec/test/delete/50_refresh.yaml new file mode 100644 index 0000000..b550789 --- /dev/null +++ b/rest-api-spec/test/delete/50_refresh.yaml @@ -0,0 +1,73 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + refresh_interval: -1 + number_of_replicas: 0 + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + refresh: 1 + + - do: + index: + index: test_1 + type: test + id: 2 + body: { foo: bar } + refresh: 1 + + - do: + search: + index: test_1 + type: test + body: + query: { terms: { _id: [1,2] }} + + - match: { hits.total: 2 } + + - do: + delete: + index: test_1 + type: test + id: 1 + + - do: + search: + index: test_1 + type: test + body: + query: { terms: { _id: [1,2] }} + + - match: { hits.total: 2 } + + - do: + delete: + index: test_1 + type: test + id: 2 + refresh: 1 + +# If a replica shard where doc 1 is located gets initialized at this point, doc 1 +# won't be found by the following search as the shard gets automatically refreshed +# right before getting started. This is why this test only works with 0 replicas. + + - do: + search: + index: test_1 + type: test + body: + query: { terms: { _id: [1,2] }} + + - match: { hits.total: 1 } diff --git a/rest-api-spec/test/delete/60_missing.yaml b/rest-api-spec/test/delete/60_missing.yaml new file mode 100644 index 0000000..9cfdb48 --- /dev/null +++ b/rest-api-spec/test/delete/60_missing.yaml @@ -0,0 +1,19 @@ +--- +"Missing document with catch": + + - do: + catch: missing + delete: + index: test_1 + type: test + id: 1 + +--- +"Missing document with ignore": + + - do: + delete: + index: test_1 + type: test + id: 1 + ignore: 404 diff --git a/rest-api-spec/test/delete/TODO.txt b/rest-api-spec/test/delete/TODO.txt new file mode 100644 index 0000000..0418363 --- /dev/null +++ b/rest-api-spec/test/delete/TODO.txt @@ -0,0 +1,6 @@ +Tests missing for: + +# consistency +# replication +# timeout + diff --git a/rest-api-spec/test/delete_by_query/10_basic.yaml b/rest-api-spec/test/delete_by_query/10_basic.yaml new file mode 100644 index 0000000..c253ad8 --- /dev/null +++ b/rest-api-spec/test/delete_by_query/10_basic.yaml @@ -0,0 +1,42 @@ +--- +"Basic delete_by_query": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 2 + body: { foo: baz } + + - do: + index: + index: test_1 + type: test + id: 3 + body: { foo: foo } + + - do: + indices.refresh: {} + + - do: + delete_by_query: + index: test_1 + body: + query: + match: + foo: bar + + - do: + indices.refresh: {} + + - do: + count: + index: test_1 + + - match: { count: 2 } diff --git a/rest-api-spec/test/exists/10_basic.yaml b/rest-api-spec/test/exists/10_basic.yaml new file mode 100644 index 0000000..ee6d73f --- /dev/null +++ b/rest-api-spec/test/exists/10_basic.yaml @@ -0,0 +1,27 @@ +--- +"Basic": + + - do: + exists: + index: test_1 + type: test + id: 1 + + - is_false: '' + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + + - is_true: '' diff --git a/rest-api-spec/test/exists/30_parent.yaml b/rest-api-spec/test/exists/30_parent.yaml new file mode 100644 index 0000000..0f84a1c --- /dev/null +++ b/rest-api-spec/test/exists/30_parent.yaml @@ -0,0 +1,42 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + +--- +"Parent": + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + - do: + exists: + index: test_1 + type: test + id: 1 + parent: 5 + + - is_true: '' + +--- +"Parent omitted": + + - do: + catch: request + exists: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/exists/40_routing.yaml b/rest-api-spec/test/exists/40_routing.yaml new file mode 100644 index 0000000..56ba443 --- /dev/null +++ b/rest-api-spec/test/exists/40_routing.yaml @@ -0,0 +1,39 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + exists: + index: test_1 + type: test + id: 1 + routing: 5 + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + + - is_false: '' diff --git a/rest-api-spec/test/exists/55_parent_with_routing.yaml b/rest-api-spec/test/exists/55_parent_with_routing.yaml new file mode 100644 index 0000000..0e92aac --- /dev/null +++ b/rest-api-spec/test/exists/55_parent_with_routing.yaml @@ -0,0 +1,56 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: { foo: bar } + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + parent: 5 + + - is_false: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + routing: 4 + + - is_true: '' + diff --git a/rest-api-spec/test/exists/60_realtime_refresh.yaml b/rest-api-spec/test/exists/60_realtime_refresh.yaml new file mode 100644 index 0000000..1025747 --- /dev/null +++ b/rest-api-spec/test/exists/60_realtime_refresh.yaml @@ -0,0 +1,50 @@ +--- +"Realtime Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + exists: + index: test_1 + type: test + id: 1 + realtime: 1 + + - is_true: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + realtime: 0 + + - is_false: '' + + - do: + exists: + index: test_1 + type: test + id: 1 + realtime: 0 + refresh: 1 + + - is_true: '' diff --git a/rest-api-spec/test/exists/70_defaults.yaml b/rest-api-spec/test/exists/70_defaults.yaml new file mode 100644 index 0000000..2db28f6 --- /dev/null +++ b/rest-api-spec/test/exists/70_defaults.yaml @@ -0,0 +1,17 @@ +--- +"Client-side default type": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + exists: + index: test_1 + type: _all + id: 1 + + - is_true: '' diff --git a/rest-api-spec/test/exists/TODO.txt b/rest-api-spec/test/exists/TODO.txt new file mode 100644 index 0000000..340ff57 --- /dev/null +++ b/rest-api-spec/test/exists/TODO.txt @@ -0,0 +1,3 @@ +Tests missing for: + +# preference diff --git a/rest-api-spec/test/explain/10_basic.yaml b/rest-api-spec/test/explain/10_basic.yaml new file mode 100644 index 0000000..fa68dfa --- /dev/null +++ b/rest-api-spec/test/explain/10_basic.yaml @@ -0,0 +1,23 @@ +--- +"Basic mlt": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar, title: howdy } + + - do: + indices.refresh: {} + + - do: + explain: + index: test_1 + type: test + id: 1 + body: + query: + match_all: {} + + - is_true: matched + - match: { explanation.value: 1 } diff --git a/rest-api-spec/test/explain/20_source_filtering.yaml b/rest-api-spec/test/explain/20_source_filtering.yaml new file mode 100644 index 0000000..04aac33 --- /dev/null +++ b/rest-api-spec/test/explain/20_source_filtering.yaml @@ -0,0 +1,44 @@ +--- +"Source filtering": + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + - do: + indices.refresh: + index: test_1 + + - do: + explain: { index: test_1, type: test, id: 1, _source: false, body: { query: { match_all: {}} } } + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - is_false: get._source + + - do: + explain: { index: test_1, type: test, id: 1, _source: true, body: { query: { match_all: {}} } } + - match: { get._source.include.field1: v1 } + + - do: + explain: { index: test_1, type: test, id: 1, _source: include.field1, body: { query: { match_all: {}} } } + - match: { get._source.include.field1: v1 } + - is_false: get._source.include.field2 + + - do: + explain: { index: test_1, type: test, id: 1, _source_include: include.field1, body: { query: { match_all: {}} } } + - match: { get._source.include.field1: v1 } + - is_false: get._source.include.field2 + + - do: + explain: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2", body: { query: { match_all: {}} } } + - match: { get._source.include.field1: v1 } + - match: { get._source.include.field2: v2 } + - is_false: get._source.count + + - do: + explain: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2", body: { query: { match_all: {}} } } + - match: { get._source.include.field1: v1 } + - is_false: get._source.include.field2 + - is_false: get._source.count diff --git a/rest-api-spec/test/explain/TODO.txt b/rest-api-spec/test/explain/TODO.txt new file mode 100644 index 0000000..2362d9d --- /dev/null +++ b/rest-api-spec/test/explain/TODO.txt @@ -0,0 +1,6 @@ +Tests missing for: + +- everything :) + + +# preference diff --git a/rest-api-spec/test/get/10_basic.yaml b/rest-api-spec/test/get/10_basic.yaml new file mode 100644 index 0000000..0689f71 --- /dev/null +++ b/rest-api-spec/test/get/10_basic.yaml @@ -0,0 +1,31 @@ +--- +"Basic": + + - do: + index: + index: test_1 + type: test + id: 中文 + body: { "foo": "Hello: 中文" } + + - do: + get: + index: test_1 + type: test + id: 中文 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: 中文 } + - match: { _source: { foo: "Hello: 中文" } } + + - do: + get: + index: test_1 + type: _all + id: 中文 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: 中文 } + - match: { _source: { foo: "Hello: 中文" } } diff --git a/rest-api-spec/test/get/15_default_values.yaml b/rest-api-spec/test/get/15_default_values.yaml new file mode 100644 index 0000000..5e08112 --- /dev/null +++ b/rest-api-spec/test/get/15_default_values.yaml @@ -0,0 +1,21 @@ +--- +"Default values": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + get: + index: test_1 + type: _all + id: 1 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: '1' } + - match: { _source: { foo: "bar" } } + diff --git a/rest-api-spec/test/get/20_fields.yaml b/rest-api-spec/test/get/20_fields.yaml new file mode 100644 index 0000000..15530b8 --- /dev/null +++ b/rest-api-spec/test/get/20_fields.yaml @@ -0,0 +1,45 @@ +--- +"Fields": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar", "count": 1 } + - do: + get: + index: test_1 + type: test + id: 1 + fields: foo + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: '1' } + - match: { fields.foo: [bar] } + - is_false: _source + + - do: + get: + index: test_1 + type: test + id: 1 + fields: [foo, count] + + - match: { fields.foo: [bar] } + - match: { fields.count: [1] } + - is_false: _source + + - do: + get: + index: test_1 + type: test + id: 1 + fields: [foo, count, _source] + + - match: { fields.foo: [bar] } + - match: { fields.count: [1] } + - match: { _source.foo: bar } + + diff --git a/rest-api-spec/test/get/30_parent.yaml b/rest-api-spec/test/get/30_parent.yaml new file mode 100644 index 0000000..f7f31d0 --- /dev/null +++ b/rest-api-spec/test/get/30_parent.yaml @@ -0,0 +1,45 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 中文 + body: { foo: bar } + +--- +"Parent": + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 中文 + fields: [_parent, _routing] + + - match: { _id: "1"} + - match: { fields._parent: 中文 } + - match: { fields._routing: 中文} + +--- +"Parent omitted": + - do: + catch: request + get: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/get/40_routing.yaml b/rest-api-spec/test/get/40_routing.yaml new file mode 100644 index 0000000..f909cb0 --- /dev/null +++ b/rest-api-spec/test/get/40_routing.yaml @@ -0,0 +1,41 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + fields: [_routing] + + - match: { _id: "1"} + - match: { fields._routing: "5"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/get/55_parent_with_routing.yaml b/rest-api-spec/test/get/55_parent_with_routing.yaml new file mode 100644 index 0000000..43d60f5 --- /dev/null +++ b/rest-api-spec/test/get/55_parent_with_routing.yaml @@ -0,0 +1,54 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + fields: [_parent, _routing] + + - match: { _id: "1"} + - match: { fields._parent: "5"} + - match: { fields._routing: "4"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + parent: 5 + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 4 + diff --git a/rest-api-spec/test/get/60_realtime_refresh.yaml b/rest-api-spec/test/get/60_realtime_refresh.yaml new file mode 100644 index 0000000..4631bed --- /dev/null +++ b/rest-api-spec/test/get/60_realtime_refresh.yaml @@ -0,0 +1,49 @@ +--- +"Realtime Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + realtime: 1 + + - is_true: found + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + realtime: 0 + + - do: + get: + index: test_1 + type: test + id: 1 + realtime: 0 + refresh: 1 + + - is_true: found diff --git a/rest-api-spec/test/get/70_source_filtering.yaml b/rest-api-spec/test/get/70_source_filtering.yaml new file mode 100644 index 0000000..03572bb --- /dev/null +++ b/rest-api-spec/test/get/70_source_filtering.yaml @@ -0,0 +1,56 @@ +--- +"Source filtering": + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + - do: + get: { index: test_1, type: test, id: 1, _source: false } + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - is_false: _source + + - do: + get: { index: test_1, type: test, id: 1, _source: true } + - match: { _source.include.field1: v1 } + + - do: + get: { index: test_1, type: test, id: 1, _source: include.field1 } + - match: { _source.include.field1: v1 } + - is_false: _source.include.field2 + + - do: + get: { index: test_1, type: test, id: 1, _source_include: include.field1 } + - match: { _source.include.field1: v1 } + - is_false: _source.include.field2 + + - do: + get: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2" } + - match: { _source.include.field1: v1 } + - match: { _source.include.field2: v2 } + - is_false: _source.count + + - do: + get: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2" } + - match: { _source.include.field1: v1 } + - is_false: _source.include.field2 + - is_false: _source.count + + + - do: + get: + index: test_1 + type: test + id: 1 + fields: count + _source: true + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - match: { fields.count: [1] } + - match: { _source.include.field1: v1 } diff --git a/rest-api-spec/test/get/80_missing.yaml b/rest-api-spec/test/get/80_missing.yaml new file mode 100644 index 0000000..a60d113 --- /dev/null +++ b/rest-api-spec/test/get/80_missing.yaml @@ -0,0 +1,19 @@ +--- +"Missing document with catch": + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + +--- +"Missing document with ignore": + + - do: + get: + index: test_1 + type: test + id: 1 + ignore: 404 diff --git a/rest-api-spec/test/get/TODO.txt b/rest-api-spec/test/get/TODO.txt new file mode 100644 index 0000000..340ff57 --- /dev/null +++ b/rest-api-spec/test/get/TODO.txt @@ -0,0 +1,3 @@ +Tests missing for: + +# preference diff --git a/rest-api-spec/test/get_source/10_basic.yaml b/rest-api-spec/test/get_source/10_basic.yaml new file mode 100644 index 0000000..b20357c --- /dev/null +++ b/rest-api-spec/test/get_source/10_basic.yaml @@ -0,0 +1,24 @@ +--- +"Basic": + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + get_source: + index: test_1 + type: test + id: 1 + + - match: { '': { foo: bar } } + + - do: + get_source: + index: test_1 + type: _all + id: 1 + + - match: { '': { foo: bar } } diff --git a/rest-api-spec/test/get_source/15_default_values.yaml b/rest-api-spec/test/get_source/15_default_values.yaml new file mode 100644 index 0000000..3e67c62 --- /dev/null +++ b/rest-api-spec/test/get_source/15_default_values.yaml @@ -0,0 +1,16 @@ +--- +"Default values": + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + get_source: + index: test_1 + type: _all + id: 1 + + - match: { '': { foo: bar } } diff --git a/rest-api-spec/test/get_source/30_parent.yaml b/rest-api-spec/test/get_source/30_parent.yaml new file mode 100644 index 0000000..35edb90 --- /dev/null +++ b/rest-api-spec/test/get_source/30_parent.yaml @@ -0,0 +1,43 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + +--- +"Parent": + - do: + get_source: + index: test_1 + type: test + id: 1 + parent: 5 + + - match: { '': {foo: bar}} + +--- +"Parent omitted": + + - do: + catch: request + get_source: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/get_source/40_routing.yaml b/rest-api-spec/test/get_source/40_routing.yaml new file mode 100644 index 0000000..f771dbb --- /dev/null +++ b/rest-api-spec/test/get_source/40_routing.yaml @@ -0,0 +1,39 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + get_source: + index: test_1 + type: test + id: 1 + routing: 5 + + - match: { '': {foo: bar}} + + - do: + catch: missing + get_source: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/get_source/55_parent_with_routing.yaml b/rest-api-spec/test/get_source/55_parent_with_routing.yaml new file mode 100644 index 0000000..86fe2ba --- /dev/null +++ b/rest-api-spec/test/get_source/55_parent_with_routing.yaml @@ -0,0 +1,51 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: { foo: bar } + + - do: + get_source: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + + - match: { '': {foo: bar}} + + - do: + catch: missing + get_source: + index: test_1 + type: test + id: 1 + parent: 5 + + - do: + get_source: + index: test_1 + type: test + id: 1 + routing: 4 + diff --git a/rest-api-spec/test/get_source/60_realtime_refresh.yaml b/rest-api-spec/test/get_source/60_realtime_refresh.yaml new file mode 100644 index 0000000..92f21ca --- /dev/null +++ b/rest-api-spec/test/get_source/60_realtime_refresh.yaml @@ -0,0 +1,50 @@ +--- +"Realtime": + + + - do: + indices.create: + index: test_1 + body: + settings: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + get_source: + index: test_1 + type: test + id: 1 + realtime: 1 + + - match: { '': {foo: bar}} + + - do: + catch: missing + get_source: + index: test_1 + type: test + id: 1 + realtime: 0 + + - do: + get_source: + index: test_1 + type: test + id: 1 + realtime: 0 + refresh: 1 + + - match: { '': {foo: bar}} + diff --git a/rest-api-spec/test/get_source/70_source_filtering.yaml b/rest-api-spec/test/get_source/70_source_filtering.yaml new file mode 100644 index 0000000..cc168ac --- /dev/null +++ b/rest-api-spec/test/get_source/70_source_filtering.yaml @@ -0,0 +1,26 @@ +--- +"Source filtering": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + + - do: + get_source: { index: test_1, type: test, id: 1, _source_include: include.field1 } + - match: { include.field1: v1 } + - is_false: include.field2 + + - do: + get_source: { index: test_1, type: test, id: 1, _source_include: "include.field1,include.field2" } + - match: { include.field1: v1 } + - match: { include.field2: v2 } + - is_false: count + + - do: + get_source: { index: test_1, type: test, id: 1, _source_include: include, _source_exclude: "*.field2" } + - match: { include.field1: v1 } + - is_false: include.field2 + - is_false: count diff --git a/rest-api-spec/test/get_source/80_missing.yaml b/rest-api-spec/test/get_source/80_missing.yaml new file mode 100644 index 0000000..fba8540 --- /dev/null +++ b/rest-api-spec/test/get_source/80_missing.yaml @@ -0,0 +1,19 @@ +--- +"Missing document with catch": + + - do: + catch: missing + get_source: + index: test_1 + type: test + id: 1 + +--- +"Missing document with ignore": + + - do: + get_source: + index: test_1 + type: test + id: 1 + ignore: 404 diff --git a/rest-api-spec/test/get_source/TODO.txt b/rest-api-spec/test/get_source/TODO.txt new file mode 100644 index 0000000..340ff57 --- /dev/null +++ b/rest-api-spec/test/get_source/TODO.txt @@ -0,0 +1,3 @@ +Tests missing for: + +# preference diff --git a/rest-api-spec/test/index/10_with_id.yaml b/rest-api-spec/test/index/10_with_id.yaml new file mode 100644 index 0000000..745e111 --- /dev/null +++ b/rest-api-spec/test/index/10_with_id.yaml @@ -0,0 +1,26 @@ +--- +"Index with ID": + + - do: + index: + index: test-weird-index-中文 + type: weird.type + id: 1 + body: { foo: bar } + + - match: { _index: test-weird-index-中文 } + - match: { _type: weird.type } + - match: { _id: "1"} + - match: { _version: 1} + + - do: + get: + index: test-weird-index-中文 + type: weird.type + id: 1 + + - match: { _index: test-weird-index-中文 } + - match: { _type: weird.type } + - match: { _id: "1"} + - match: { _version: 1} + - match: { _source: { foo: bar }} diff --git a/rest-api-spec/test/index/15_without_id.yaml b/rest-api-spec/test/index/15_without_id.yaml new file mode 100644 index 0000000..3fff051 --- /dev/null +++ b/rest-api-spec/test/index/15_without_id.yaml @@ -0,0 +1,26 @@ +--- +"Index without ID": + + - do: + index: + index: test_1 + type: test + body: { foo: bar } + + - is_true: _id + - match: { _index: test_1 } + - match: { _type: test } + - match: { _version: 1 } + - set: { _id: id } + + - do: + get: + index: test_1 + type: test + id: '$id' + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: $id } + - match: { _version: 1 } + - match: { _source: { foo: bar }} diff --git a/rest-api-spec/test/index/20_optype.yaml b/rest-api-spec/test/index/20_optype.yaml new file mode 100644 index 0000000..60ae26d --- /dev/null +++ b/rest-api-spec/test/index/20_optype.yaml @@ -0,0 +1,29 @@ +--- +"Optype": + + - do: + index: + index: test_1 + type: test + id: 1 + op_type: create + body: { foo: bar } + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + op_type: create + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 1 + op_type: index + body: { foo: bar } + + - match: { _version: 2 } diff --git a/rest-api-spec/test/index/30_internal_version.yaml b/rest-api-spec/test/index/30_internal_version.yaml new file mode 100644 index 0000000..1767fbe --- /dev/null +++ b/rest-api-spec/test/index/30_internal_version.yaml @@ -0,0 +1,36 @@ +--- +"Internal version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + - match: { _version: 1} + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + - match: { _version: 2} + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version: 1 + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version: 2 + + - match: { _version: 3 } diff --git a/rest-api-spec/test/index/35_external_version.yaml b/rest-api-spec/test/index/35_external_version.yaml new file mode 100644 index 0000000..0f8f923 --- /dev/null +++ b/rest-api-spec/test/index/35_external_version.yaml @@ -0,0 +1,34 @@ +--- +"External version": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - match: { _version: 5} + + - do: + catch: conflict + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 5 + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + version_type: external + version: 6 + + - match: { _version: 6} diff --git a/rest-api-spec/test/index/40_routing.yaml b/rest-api-spec/test/index/40_routing.yaml new file mode 100644 index 0000000..f909cb0 --- /dev/null +++ b/rest-api-spec/test/index/40_routing.yaml @@ -0,0 +1,41 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + fields: [_routing] + + - match: { _id: "1"} + - match: { fields._routing: "5"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + diff --git a/rest-api-spec/test/index/50_parent.yaml b/rest-api-spec/test/index/50_parent.yaml new file mode 100644 index 0000000..551d30d --- /dev/null +++ b/rest-api-spec/test/index/50_parent.yaml @@ -0,0 +1,42 @@ +--- +"Parent": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - do: + catch: /RoutingMissingException/ + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + fields: [_parent, _routing] + + - match: { _id: "1"} + - match: { fields._parent: "5"} + - match: { fields._routing: "5"} + diff --git a/rest-api-spec/test/index/55_parent_with_routing.yaml b/rest-api-spec/test/index/55_parent_with_routing.yaml new file mode 100644 index 0000000..43d60f5 --- /dev/null +++ b/rest-api-spec/test/index/55_parent_with_routing.yaml @@ -0,0 +1,54 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + fields: [_parent, _routing] + + - match: { _id: "1"} + - match: { fields._parent: "5"} + - match: { fields._routing: "4"} + + - do: + catch: missing + get: + index: test_1 + type: test + id: 1 + parent: 5 + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 4 + diff --git a/rest-api-spec/test/index/60_refresh.yaml b/rest-api-spec/test/index/60_refresh.yaml new file mode 100644 index 0000000..af6ea59 --- /dev/null +++ b/rest-api-spec/test/index/60_refresh.yaml @@ -0,0 +1,46 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index.refresh_interval: -1 + number_of_replicas: 0 + - do: + cluster.health: + wait_for_status: yellow + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + search: + index: test_1 + type: test + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 0 } + + - do: + index: + index: test_1 + type: test + id: 2 + refresh: 1 + body: { foo: bar } + + - do: + search: + index: test_1 + type: test + body: + query: { term: { _id: 2 }} + + - match: { hits.total: 1 } diff --git a/rest-api-spec/test/index/70_timestamp.yaml b/rest-api-spec/test/index/70_timestamp.yaml new file mode 100644 index 0000000..9e94795 --- /dev/null +++ b/rest-api-spec/test/index/70_timestamp.yaml @@ -0,0 +1,71 @@ +--- +"Timestamp": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _timestamp: + enabled: 1 + store: yes + - do: + cluster.health: + wait_for_status: yellow + +# blank timestamp + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - is_true: fields._timestamp + +# milliseconds since epoch + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + timestamp: 1372011280000 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - match: { fields._timestamp: 1372011280000 } + +# date format + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + timestamp: 2013-06-23T18:14:40 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - match: { fields._timestamp: 1372011280000 } + diff --git a/rest-api-spec/test/index/75_ttl.yaml b/rest-api-spec/test/index/75_ttl.yaml new file mode 100644 index 0000000..08a7db8 --- /dev/null +++ b/rest-api-spec/test/index/75_ttl.yaml @@ -0,0 +1,88 @@ +--- +"TTL": + + - skip: + features: gtelte + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _ttl: + enabled: 1 + store: yes + default: 10s + - do: + cluster.health: + wait_for_status: yellow + +# blank ttl + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 10000} + - gt: { fields._ttl: 0} + +# milliseconds + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 100000 + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 100000} + - gt: { fields._ttl: 10000} + +# duration + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 20s + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 20000} + - gt: { fields._ttl: 10000} + +# with timestamp + + - do: + catch: /AlreadyExpiredException/ + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 20s + timestamp: 2013-06-23T18:14:40 + diff --git a/rest-api-spec/test/index/TODO.txt b/rest-api-spec/test/index/TODO.txt new file mode 100644 index 0000000..d8a93ca --- /dev/null +++ b/rest-api-spec/test/index/TODO.txt @@ -0,0 +1,5 @@ +Tests missing for: + +# consistency +# percolate +# replication diff --git a/rest-api-spec/test/indices.analyze/10_analyze.yaml b/rest-api-spec/test/indices.analyze/10_analyze.yaml new file mode 100644 index 0000000..d3af1e3 --- /dev/null +++ b/rest-api-spec/test/indices.analyze/10_analyze.yaml @@ -0,0 +1,50 @@ +# Will be performed before each test as a part of the test setup +# +setup: + - do: + ping: {} + +--- +"Basic test": + - do: + indices.analyze: + text: Foo Bar + - length: { tokens: 2 } + - match: { tokens.0.token: foo } + - match: { tokens.1.token: bar } + +--- +"Tokenizer and filter": + - do: + indices.analyze: + filters: lowercase + text: Foo Bar + tokenizer: keyword + - length: { tokens: 1 } + - match: { tokens.0.token: foo bar } + +--- +"Index and field": + - do: + indices.create: + index: test + body: + mappings: + test: + properties: + text: + type: string + analyzer: whitespace + - do: + cluster.health: + wait_for_status: yellow + + + - do: + indices.analyze: + field: text + index: test + text: Foo Bar! + - length: { tokens: 2 } + - match: { tokens.0.token: Foo } + - match: { tokens.1.token: Bar! } diff --git a/rest-api-spec/test/indices.clear_cache/10_basic.yaml b/rest-api-spec/test/indices.clear_cache/10_basic.yaml new file mode 100644 index 0000000..3388d06 --- /dev/null +++ b/rest-api-spec/test/indices.clear_cache/10_basic.yaml @@ -0,0 +1,4 @@ +--- +"clear_cache test": + - do: + indices.clear_cache: {} diff --git a/rest-api-spec/test/indices.create/10_basic.yaml b/rest-api-spec/test/indices.create/10_basic.yaml new file mode 100644 index 0000000..2cb979b --- /dev/null +++ b/rest-api-spec/test/indices.create/10_basic.yaml @@ -0,0 +1,85 @@ +--- +"Create index with mappings": + + - do: + indices.create: + index: test_index + body: + mappings: + type_1: {} + + - do: + indices.get_mapping: + index: test_index + + - match: { test_index.mappings.type_1.properties: {}} + +--- +"Create index with settings": + + - do: + indices.create: + index: test_index + body: + settings: + number_of_replicas: "0" + + - do: + indices.get_settings: + index: test_index + + - match: { test_index.settings.index.number_of_replicas: "0"} + +--- +"Create index with warmers": + + - do: + indices.create: + index: test_index + body: + warmers: + test_warmer: + source: + query: + match_all: {} + + - do: + indices.get_warmer: + index: test_index + + - match: {test_index.warmers.test_warmer.source.query.match_all: {}} + +--- +"Create index with mappings, settings and warmers": + + - do: + indices.create: + index: test_index + body: + mappings: + type_1: {} + settings: + number_of_replicas: "0" + warmers: + test_warmer: + source: + query: + match_all: {} + + - do: + indices.get_mapping: + index: test_index + + - match: { test_index.mappings.type_1.properties: {}} + + - do: + indices.get_settings: + index: test_index + + - match: { test_index.settings.index.number_of_replicas: "0"} + + - do: + indices.get_warmer: + index: test_index + + - match: { test_index.warmers.test_warmer.source.query.match_all: {}} diff --git a/rest-api-spec/test/indices.delete_alias/10_basic.yaml b/rest-api-spec/test/indices.delete_alias/10_basic.yaml new file mode 100644 index 0000000..87f61ef --- /dev/null +++ b/rest-api-spec/test/indices.delete_alias/10_basic.yaml @@ -0,0 +1,32 @@ +--- +"Basic test for delete alias": + + - do: + indices.create: + index: testind + + - do: + indices.put_alias: + index: testind + name: testali + body: + routing: "routing value" + + - do: + indices.get_alias: + name: testali + + - match: {testind.aliases.testali.search_routing: "routing value"} + - match: {testind.aliases.testali.index_routing: "routing value"} + + - do: + indices.delete_alias: + index: testind + name: testali + + - do: + indices.get_alias: + index: testind + name: testali + + - match: { '': {}} diff --git a/rest-api-spec/test/indices.delete_alias/all_path_options.yaml b/rest-api-spec/test/indices.delete_alias/all_path_options.yaml new file mode 100644 index 0000000..bd158c3 --- /dev/null +++ b/rest-api-spec/test/indices.delete_alias/all_path_options.yaml @@ -0,0 +1,225 @@ +--- +setup: + + - do: + indices.create: + index: test_index1 + + - do: + indices.create: + index: test_index2 + + - do: + indices.create: + index: foo + + - do: + indices.put_alias: + name: alias1 + body: + routing: "routing value" + - do: + indices.put_alias: + name: alias2 + body: + routing: "routing value" + +--- +"check setup": + - do: + indices.get_alias: + name: alias1 + + - match: {test_index1.aliases.alias1.search_routing: "routing value"} + - match: {test_index2.aliases.alias1.search_routing: "routing value"} + - match: {foo.aliases.alias1.search_routing: "routing value"} + + - do: + indices.get_alias: + name: alias2 + + - match: {test_index1.aliases.alias2.search_routing: "routing value"} + - match: {test_index2.aliases.alias2.search_routing: "routing value"} + - match: {foo.aliases.alias2.search_routing: "routing value"} + +--- +"check delete with _all index": + - do: + indices.delete_alias: + index: _all + name: alias1 + + - do: + catch: missing + indices.get_alias: + name: alias1 + - do: + indices.get_alias: + name: alias2 + + - match: {test_index1.aliases.alias2.search_routing: "routing value"} + - match: {test_index2.aliases.alias2.search_routing: "routing value"} + - match: {foo.aliases.alias2.search_routing: "routing value"} + +--- +"check delete with * index": + - do: + indices.delete_alias: + index: "*" + name: alias1 + + - do: + catch: missing + indices.get_alias: + name: alias1 + - do: + indices.get_alias: + name: alias2 + + - match: {test_index1.aliases.alias2.search_routing: "routing value"} + - match: {test_index2.aliases.alias2.search_routing: "routing value"} + - match: {foo.aliases.alias2.search_routing: "routing value"} + +--- +"check delete with index list": + - do: + indices.delete_alias: + index: "test_index1,test_index2" + name: alias1 + + - do: + indices.get_alias: + name: alias1 + + - match: {foo.aliases.alias1.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_alias: + name: alias2 + + - match: {test_index1.aliases.alias2.search_routing: "routing value"} + - match: {test_index2.aliases.alias2.search_routing: "routing value"} + - match: {foo.aliases.alias2.search_routing: "routing value"} + +--- +"check delete with prefix* index": + - do: + indices.delete_alias: + index: "test_*" + name: alias1 + + - do: + indices.get_alias: + name: alias1 + + - match: {foo.aliases.alias1.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_alias: + name: alias2 + + - match: {test_index1.aliases.alias2.search_routing: "routing value"} + - match: {test_index2.aliases.alias2.search_routing: "routing value"} + - match: {foo.aliases.alias2.search_routing: "routing value"} + + +--- +"check delete with index list and * aliases": + - do: + indices.delete_alias: + index: "test_index1,test_index2" + name: "*" + + - do: + indices.get_alias: + name: alias1 + + - match: {foo.aliases.alias1.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_alias: + name: alias2 + + - match: {foo.aliases.alias2.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + +--- +"check delete with index list and _all aliases": + - do: + indices.delete_alias: + index: "test_index1,test_index2" + name: _all + + - do: + indices.get_alias: + name: alias1 + + - match: {foo.aliases.alias1.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_alias: + name: alias2 + + - match: {foo.aliases.alias2.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + +--- +"check delete with index list and wildcard aliases": + - do: + indices.delete_alias: + index: "test_index1,test_index2" + name: "*1" + + - do: + indices.get_alias: + name: alias1 + + - match: {foo.aliases.alias1.search_routing: "routing value"} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_alias: + name: alias2 + + - match: {test_index1.aliases.alias2.search_routing: "routing value"} + - match: {test_index2.aliases.alias2.search_routing: "routing value"} + - match: {foo.aliases.alias2.search_routing: "routing value"} + +--- +"check 404 on no matching alias": + - do: + catch: missing + indices.delete_alias: + index: "*" + name: "non_existent" + + - do: + catch: missing + indices.delete_alias: + index: "non_existent" + name: "alias1" + + +--- +"check delete with blank index and blank alias": + - do: + catch: param + indices.delete_alias: + name: "alias1" + + - do: + catch: param + indices.delete_alias: + index: "test_index1" + diff --git a/rest-api-spec/test/indices.delete_mapping/10_basic.yaml b/rest-api-spec/test/indices.delete_mapping/10_basic.yaml new file mode 100644 index 0000000..e7139bc --- /dev/null +++ b/rest-api-spec/test/indices.delete_mapping/10_basic.yaml @@ -0,0 +1,31 @@ +--- +"delete mapping tests": + - do: + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.exists_type: + index: test_index + type: test_type + + - is_true: '' + + - do: + indices.delete_mapping: + index: test_index + type: test_type + + - do: + indices.exists_type: + index: test_index + type: test_type + + - is_false: '' diff --git a/rest-api-spec/test/indices.delete_mapping/all_path_options.yaml b/rest-api-spec/test/indices.delete_mapping/all_path_options.yaml new file mode 100644 index 0000000..90a8656 --- /dev/null +++ b/rest-api-spec/test/indices.delete_mapping/all_path_options.yaml @@ -0,0 +1,272 @@ +setup: + + - do: + indices.create: + index: test_index1 + body: + mappings: { test_type1: { }} + + - do: + indices.create: + index: test_index2 + body: + mappings: { test_type2: { }} + - do: + indices.create: + index: foo + body: + mappings: { test_type2: { }} + +--- +"delete with _all index": + - do: + indices.delete_mapping: + index: _all + type: test_type2 + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_true: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_false: '' + +--- +"delete with * index": + - do: + indices.delete_mapping: + index: '*' + type: test_type2 + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_true: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_false: '' + +--- +"delete with prefix* index": + - do: + indices.delete_mapping: + index: test* + type: test_type2 + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_true: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_true: '' + +--- +"delete with list of indices": + + - do: + indices.delete_mapping: + index: test_index1,test_index2 + type: test_type2 + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_true: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_true: '' + +--- +"delete with index list and _all type": + - do: + indices.delete_mapping: + index: test_index1,test_index2 + type: _all + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_false: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_true: '' + + +--- +"delete with index list and * type": + - do: + indices.delete_mapping: + index: test_index1,test_index2 + type: '*' + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_false: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_true: '' + + +--- +"delete with index list and prefix* type": + - do: + indices.delete_mapping: + index: test_index1,test_index2 + type: '*2' + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_true: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_true: '' + +--- +"delete with index list and list of types": + - do: + indices.delete_mapping: + index: test_index1,test_index2 + type: test_type1,test_type2 + + - do: + indices.exists_type: + index: test_index1 + type: test_type1 + + - is_false: '' + + - do: + indices.exists_type: + index: test_index2 + type: test_type2 + + - is_false: '' + + - do: + indices.exists_type: + index: foo + type: test_type2 + + - is_true: '' + +--- +"check 404 on no matching type": + - do: + catch: missing + indices.delete_mapping: + index: "*" + type: "non_existent" + + - do: + catch: missing + indices.delete_mapping: + index: "non_existent" + type: "test_type1" + +--- +"check delete with blank index and blank type": + - do: + catch: param + indices.delete_mapping: + name: "test_type1" + + - do: + catch: param + indices.delete_mapping: + index: "test_index1" + diff --git a/rest-api-spec/test/indices.delete_warmer/all_path_options.yaml b/rest-api-spec/test/indices.delete_warmer/all_path_options.yaml new file mode 100644 index 0000000..603b01c --- /dev/null +++ b/rest-api-spec/test/indices.delete_warmer/all_path_options.yaml @@ -0,0 +1,218 @@ +setup: + - do: + indices.create: + index: test_index1 + body: + warmers: + test_warmer1: + source: + query: + match_all: {} + test_warmer2: + source: + query: + match_all: {} + + - do: + indices.create: + index: test_index2 + body: + warmers: + test_warmer1: + source: + query: + match_all: {} + test_warmer2: + source: + query: + match_all: {} + + - do: + indices.create: + index: foo + body: + warmers: + test_warmer1: + source: + query: + match_all: {} + test_warmer2: + source: + query: + match_all: {} + +--- +"Check setup": + + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.test_warmer1.source.query.match_all: {}} + - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer1.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}} + - match: {foo.warmers.test_warmer1.source.query.match_all: {}} + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + + +--- +"check delete with _all index": + - do: + indices.delete_warmer: + index: _all + name: test_warmer1 + + - do: + indices.get_warmer: {} + + - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}} + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + +--- +"check delete with * index": + - do: + indices.delete_warmer: + index: "*" + name: test_warmer1 + + - do: + indices.get_warmer: {} + + - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}} + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + +--- +"check delete with index list": + - do: + indices.delete_warmer: + index: "test_index1,test_index2" + name: test_warmer1 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer1' } + + - match: {foo.warmers.test_warmer1.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer2' } + + - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}} + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + +--- +"check delete with prefix* index": + - do: + indices.delete_warmer: + index: "test_*" + name: test_warmer1 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer1' } + + - match: {foo.warmers.test_warmer1.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer2' } + + - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}} + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + + +--- +"check delete with index list and * warmers": + - do: + indices.delete_warmer: + index: "test_index1,test_index2" + name: "*" + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer1' } + + - match: {foo.warmers.test_warmer1.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer2' } + + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + +--- +"check delete with index list and _all warmers": + - do: + indices.delete_warmer: + index: "test_index1,test_index2" + name: _all + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer1' } + + - match: {foo.warmers.test_warmer1.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer2' } + + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + +--- +"check delete with index list and wildcard warmers": + - do: + indices.delete_warmer: + index: "test_index1,test_index2" + name: "*1" + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer1' } + + - match: {foo.warmers.test_warmer1.source.query.match_all: {}} + - is_false: test_index1 + - is_false: test_index2 + + - do: + indices.get_warmer: { index: _all, name: 'test_warmer2' } + + - match: {test_index1.warmers.test_warmer2.source.query.match_all: {}} + - match: {test_index2.warmers.test_warmer2.source.query.match_all: {}} + - match: {foo.warmers.test_warmer2.source.query.match_all: {}} + +--- +"check 404 on no matching test_warmer": + - do: + catch: missing + indices.delete_warmer: + index: "*" + name: "non_existent" + + - do: + catch: missing + indices.delete_warmer: + index: "non_existent" + name: "test_warmer1" + + +--- +"check delete with blank index and blank test_warmer": + - do: + catch: param + indices.delete_warmer: + name: "test_warmer1" + + - do: + catch: param + indices.delete_warmer: + index: "test_index1" + diff --git a/rest-api-spec/test/indices.exists/10_basic.yaml b/rest-api-spec/test/indices.exists/10_basic.yaml new file mode 100644 index 0000000..e8bbb80 --- /dev/null +++ b/rest-api-spec/test/indices.exists/10_basic.yaml @@ -0,0 +1,25 @@ +--- +"Test indices.exists": + - do: + indices.exists: + index: test_index + + - is_false: '' + + - do: + indices.create: + index: test_index + + - do: + indices.exists: + index: test_index + + - is_true: '' +--- +"Test indices.exists with local flag": + - do: + indices.exists: + index: test_index + local: true + + - is_false: '' diff --git a/rest-api-spec/test/indices.exists_alias/10_basic.yaml b/rest-api-spec/test/indices.exists_alias/10_basic.yaml new file mode 100644 index 0000000..fba0512 --- /dev/null +++ b/rest-api-spec/test/indices.exists_alias/10_basic.yaml @@ -0,0 +1,45 @@ +--- +"Test indices.exists_alias": + - do: + indices.exists_alias: + name: test_alias + + - is_false: '' + + - do: + indices.create: + index: test_index + + - do: + indices.put_alias: + index: test_index + name: test_alias + + - do: + indices.exists_alias: + name: test_alias + + - is_true: '' + + - do: + indices.exists_alias: + index: test_index + name: test_alias + + - is_true: '' + + - do: + indices.exists_alias: + index: test_index1 + name: test_alias + + - is_false: '' + +--- +"Test indices.exists_alias with local flag": + - do: + indices.exists_alias: + name: test_alias + local: true + + - is_false: '' diff --git a/rest-api-spec/test/indices.exists_template/10_basic.yaml b/rest-api-spec/test/indices.exists_template/10_basic.yaml new file mode 100644 index 0000000..f8e5052 --- /dev/null +++ b/rest-api-spec/test/indices.exists_template/10_basic.yaml @@ -0,0 +1,38 @@ +--- +setup: + - do: + indices.delete_template: + name: test + ignore: [404] +--- +"Test indices.exists_template": + - do: + indices.exists_template: + name: test + + - is_false: '' + + - do: + indices.put_template: + name: test + body: + template: 'test-*' + settings: + number_of_shards: 1 + number_of_replicas: 0 + + - do: + indices.exists_template: + name: test + + - is_true: '' + +--- +"Test indices.exists_template with local flag": + - do: + indices.exists_template: + name: test + local: true + + - is_false: '' + diff --git a/rest-api-spec/test/indices.exists_type/10_basic.yaml b/rest-api-spec/test/indices.exists_type/10_basic.yaml new file mode 100644 index 0000000..fb0dad5 --- /dev/null +++ b/rest-api-spec/test/indices.exists_type/10_basic.yaml @@ -0,0 +1,40 @@ +--- +"Exists type": + - do: + indices.create: + index: test_1 + body: + mappings: + type_1: {} + type_2: {} + + - do: + indices.exists_type: + index: test_2 + type: type_1 + + - is_false: '' + + - do: + indices.exists_type: + index: test_1 + type: type_3 + + - is_false: '' + + - do: + indices.exists_type: + index: test_1 + type: type_1 + + - is_true: '' +--- +"Exists type with local flag": + + - do: + indices.exists_type: + index: test_1 + type: type_1 + local: true + + - is_false: '' diff --git a/rest-api-spec/test/indices.get_alias/10_basic.yaml b/rest-api-spec/test/indices.get_alias/10_basic.yaml new file mode 100644 index 0000000..42b696f --- /dev/null +++ b/rest-api-spec/test/indices.get_alias/10_basic.yaml @@ -0,0 +1,219 @@ +--- +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 + +--- +"Get alias with local flag": + + - do: + indices.get_alias: + local: true + + - is_true: test_index + + - is_true: test_index_2 diff --git a/rest-api-spec/test/indices.get_aliases/10_basic.yaml b/rest-api-spec/test/indices.get_aliases/10_basic.yaml new file mode 100644 index 0000000..73e136a --- /dev/null +++ b/rest-api-spec/test/indices.get_aliases/10_basic.yaml @@ -0,0 +1,224 @@ +--- +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 + +--- +"Get aliases with local flag": + + - do: + indices.get_aliases: + local: true + + - is_true: test_index + + - is_true: test_index_2 + + diff --git a/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml b/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml new file mode 100644 index 0000000..0b63631 --- /dev/null +++ b/rest-api-spec/test/indices.get_field_mapping/10_basic.yaml @@ -0,0 +1,79 @@ +--- +setup: + - do: + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + text: + type: string + - do: + cluster.health: + wait_for_status: yellow + +--- +"Get field mapping with no index and type": + + - do: + indices.get_field_mapping: + field: text + + - match: {test_index.mappings.test_type.text.mapping.text.type: string} + +--- +"Get field mapping by index only": + - do: + indices.get_field_mapping: + index: test_index + field: text + + - match: {test_index.mappings.test_type.text.mapping.text.type: string} + +--- +"Get field mapping by type & field": + + - do: + indices.get_field_mapping: + index: test_index + type: test_type + field: text + + - match: {test_index.mappings.test_type.text.mapping.text.type: string} + +--- +"Get field mapping by type & field, with another field that doesn't exist": + + - do: + indices.get_field_mapping: + index: test_index + type: test_type + field: [ text , text1 ] + + - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - is_false: test_index.mappings.test_type.text1 + +--- +"Get field mapping with include_defaults": + + - do: + indices.get_field_mapping: + index: test_index + type: test_type + field: text + include_defaults: true + + - match: {test_index.mappings.test_type.text.mapping.text.type: string} + - match: {test_index.mappings.test_type.text.mapping.text.analyzer: default} + +--- +"Get field mapping should work without index specifying type and field": + + - do: + indices.get_field_mapping: + type: test_type + field: text + + - match: {test_index.mappings.test_type.text.mapping.text.type: string} + diff --git a/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml b/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml new file mode 100644 index 0000000..1eae257 --- /dev/null +++ b/rest-api-spec/test/indices.get_field_mapping/20_missing_field.yaml @@ -0,0 +1,24 @@ +--- +"Return empty object if field doesn't exist, but type and index do": + + - do: + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + text: + type: string + analyzer: whitespace + - do: + cluster.health: + wait_for_status: yellow + + - do: + indices.get_field_mapping: + index: test_index + type: test_type + field: not_existent + + - match: { '': {}} diff --git a/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml b/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml new file mode 100644 index 0000000..7c16d51 --- /dev/null +++ b/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yaml @@ -0,0 +1,24 @@ +--- +"Raise 404 when type doesn't exist": + + - do: + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + text: + type: string + analyzer: whitespace + - do: + cluster.health: + wait_for_status: yellow + + - do: + catch: missing + indices.get_field_mapping: + index: test_index + type: not_test_type + field: text + diff --git a/rest-api-spec/test/indices.get_field_mapping/40_missing_index.yaml b/rest-api-spec/test/indices.get_field_mapping/40_missing_index.yaml new file mode 100644 index 0000000..ab2d985 --- /dev/null +++ b/rest-api-spec/test/indices.get_field_mapping/40_missing_index.yaml @@ -0,0 +1,11 @@ +--- +"Raise 404 when index doesn't exist": + + - do: + catch: missing + indices.get_field_mapping: + index: test_index + type: type + field: field + + diff --git a/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml b/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml new file mode 100644 index 0000000..766be05 --- /dev/null +++ b/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml @@ -0,0 +1,148 @@ +--- +setup: + - do: + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + t1: + type: string + t2: + type: string + obj: + path: just_name + properties: + t1: + type: string + i_t1: + type: string + index_name: t1 + i_t3: + type: string + index_name: t3 + + - do: + indices.create: + index: test_index_2 + body: + mappings: + test_type_2: + properties: + t1: + type: string + t2: + type: string + obj: + path: just_name + properties: + t1: + type: string + i_t1: + type: string + index_name: t1 + i_t3: + type: string + index_name: t3 + + - do: + cluster.health: + wait_for_status: yellow + +--- +"Get field mapping with * for fields": + + - do: + indices.get_field_mapping: + field: "*" + + - match: {test_index.mappings.test_type.t1.full_name: t1 } + - match: {test_index.mappings.test_type.t2.full_name: t2 } + - match: {test_index.mappings.test_type.obj\.t1.full_name: obj.t1 } + - match: {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 } + - match: {test_index.mappings.test_type.obj\.i_t3.full_name: obj.i_t3 } + +--- +"Get field mapping with t* for fields": + + - do: + indices.get_field_mapping: + index: test_index + field: "t*" + +# i_t1 matches the pattern using it's index name, but t1 already means a full name +# of a field and thus takes precedence. + - match: {test_index.mappings.test_type.t1.full_name: t1 } + - match: {test_index.mappings.test_type.t2.full_name: t2 } + - match: {test_index.mappings.test_type.t3.full_name: obj.i_t3 } + - length: {test_index.mappings.test_type: 3} + +--- +"Get field mapping with *t1 for fields": + + - do: + indices.get_field_mapping: + index: test_index + field: "*t1" + - match: {test_index.mappings.test_type.t1.full_name: t1 } + - match: {test_index.mappings.test_type.obj\.t1.full_name: obj.t1 } + - match: {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 } + - length: {test_index.mappings.test_type: 3} + +--- +"Get field mapping with wildcarded relative names": + + - do: + indices.get_field_mapping: + index: test_index + field: "i_*" + - match: {test_index.mappings.test_type.i_t1.full_name: obj.i_t1 } + - match: {test_index.mappings.test_type.i_t3.full_name: obj.i_t3 } + - length: {test_index.mappings.test_type: 2} + +--- +"Get field mapping should work using '_all' for indices and types": + + - do: + indices.get_field_mapping: + index: _all + type: _all + field: "i_*" + - match: {test_index.mappings.test_type.i_t1.full_name: obj.i_t1 } + - match: {test_index.mappings.test_type.i_t3.full_name: obj.i_t3 } + - length: {test_index.mappings.test_type: 2} + - match: {test_index_2.mappings.test_type_2.i_t1.full_name: obj.i_t1 } + - match: {test_index_2.mappings.test_type_2.i_t3.full_name: obj.i_t3 } + - length: {test_index_2.mappings.test_type_2: 2} + +--- +"Get field mapping should work using '*' for indices and types": + + - do: + indices.get_field_mapping: + index: '*' + type: '*' + field: "i_*" + - match: {test_index.mappings.test_type.i_t1.full_name: obj.i_t1 } + - match: {test_index.mappings.test_type.i_t3.full_name: obj.i_t3 } + - length: {test_index.mappings.test_type: 2} + - match: {test_index_2.mappings.test_type_2.i_t1.full_name: obj.i_t1 } + - match: {test_index_2.mappings.test_type_2.i_t3.full_name: obj.i_t3 } + - length: {test_index_2.mappings.test_type_2: 2} + +--- +"Get field mapping should work using comma_separated values for indices and types": + + - do: + indices.get_field_mapping: + index: 'test_index,test_index_2' + type: 'test_type,test_type_2' + field: "i_*" + - match: {test_index.mappings.test_type.i_t1.full_name: obj.i_t1 } + - match: {test_index.mappings.test_type.i_t3.full_name: obj.i_t3 } + - length: {test_index.mappings.test_type: 2} + - match: {test_index_2.mappings.test_type_2.i_t1.full_name: obj.i_t1 } + - match: {test_index_2.mappings.test_type_2.i_t3.full_name: obj.i_t3 } + - length: {test_index_2.mappings.test_type_2: 2} + diff --git a/rest-api-spec/test/indices.get_mapping/10_basic.yaml b/rest-api-spec/test/indices.get_mapping/10_basic.yaml new file mode 100644 index 0000000..b7e6abf --- /dev/null +++ b/rest-api-spec/test/indices.get_mapping/10_basic.yaml @@ -0,0 +1,161 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + mappings: + type_1: {} + type_2: {} + - do: + indices.create: + index: test_2 + body: + mappings: + type_2: {} + type_3: {} + +--- +"Get /_mapping": + + - 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 /{index}/_mapping": + + - do: + indices.get_mapping: + index: test_1 + + - 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,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 diff --git a/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml b/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml new file mode 100644 index 0000000..91b1883 --- /dev/null +++ b/rest-api-spec/test/indices.get_mapping/20_missing_type.yaml @@ -0,0 +1,19 @@ +--- +"Return empty response when type doesn't exist": + - do: + indices.create: + index: test_index + body: + mappings: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: + index: test_index + type: not_test_type + + - match: { '': {}} diff --git a/rest-api-spec/test/indices.get_mapping/30_missing_index.yaml b/rest-api-spec/test/indices.get_mapping/30_missing_index.yaml new file mode 100644 index 0000000..6aadb37 --- /dev/null +++ b/rest-api-spec/test/indices.get_mapping/30_missing_index.yaml @@ -0,0 +1,9 @@ +--- +"Raise 404 when index doesn't exist": + - do: + catch: missing + indices.get_mapping: + index: test_index + type: not_test_type + + diff --git a/rest-api-spec/test/indices.get_mapping/40_aliases.yaml b/rest-api-spec/test/indices.get_mapping/40_aliases.yaml new file mode 100644 index 0000000..9dff6ed --- /dev/null +++ b/rest-api-spec/test/indices.get_mapping/40_aliases.yaml @@ -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} + diff --git a/rest-api-spec/test/indices.get_settings/10_basic.yaml b/rest-api-spec/test/indices.get_settings/10_basic.yaml new file mode 100644 index 0000000..eaca930 --- /dev/null +++ b/rest-api-spec/test/indices.get_settings/10_basic.yaml @@ -0,0 +1,165 @@ +--- +setup: + - do: + indices.create: + index: test_1 + - do: + indices.create: + index: test_2 + +--- +"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 + 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 /*/_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,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 + +--- +"Get /_settings with local flag": + + - do: + indices.get_settings: + local: true + + - is_true: test_1 + - is_true: test_2 diff --git a/rest-api-spec/test/indices.get_settings/20_aliases.yaml b/rest-api-spec/test/indices.get_settings/20_aliases.yaml new file mode 100644 index 0000000..da76782 --- /dev/null +++ b/rest-api-spec/test/indices.get_settings/20_aliases.yaml @@ -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" } + diff --git a/rest-api-spec/test/indices.get_template/10_basic.yaml b/rest-api-spec/test/indices.get_template/10_basic.yaml new file mode 100644 index 0000000..f5a4cad --- /dev/null +++ b/rest-api-spec/test/indices.get_template/10_basic.yaml @@ -0,0 +1,45 @@ +setup: + - do: + indices.put_template: + name: test + body: + template: test-* + settings: + number_of_shards: 1 + number_of_replicas: 0 + +--- +"Get template": + + - do: + indices.get_template: + name: test + + - match: {test.template: "test-*"} + - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} +--- +"Get all templates": + + - do: + indices.put_template: + name: test2 + body: + template: test2-* + settings: + number_of_shards: 1 + + - do: + indices.get_template: {} + + - match: {test.template: "test-*"} + - match: {test2.template: "test2-*"} + +--- +"Get template with local flag": + + - do: + indices.get_template: + name: test + local: true + + - is_true: test diff --git a/rest-api-spec/test/indices.get_template/20_get_missing.yaml b/rest-api-spec/test/indices.get_template/20_get_missing.yaml new file mode 100644 index 0000000..2751f57 --- /dev/null +++ b/rest-api-spec/test/indices.get_template/20_get_missing.yaml @@ -0,0 +1,13 @@ +setup: + - do: + indices.delete_template: + name: '*' + ignore: 404 +--- +"Get missing template": + + - do: + catch: missing + indices.get_template: + name: test + diff --git a/rest-api-spec/test/indices.get_warmer/10_basic.yaml b/rest-api-spec/test/indices.get_warmer/10_basic.yaml new file mode 100644 index 0000000..668a611 --- /dev/null +++ b/rest-api-spec/test/indices.get_warmer/10_basic.yaml @@ -0,0 +1,201 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + warmers: + warmer_1: + source: { query: { match_all: { }}} + warmer_2: + source: { query: { match_all: { }}} + + + - do: + indices.create: + index: test_2 + body: + warmers: + warmer_2: + source: { query: { match_all: { }}} + warmer_3: + source: { query: { match_all: { }}} + + - do: + cluster.health: + wait_for_status: yellow + +--- +"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,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: '*' + +--- +"Get /_warmer with local flag": + + - do: + indices.get_warmer: + local: true + + - is_true: test_1 + - is_true: test_2 + diff --git a/rest-api-spec/test/indices.open/10_basic.yaml b/rest-api-spec/test/indices.open/10_basic.yaml new file mode 100644 index 0000000..6b8846b --- /dev/null +++ b/rest-api-spec/test/indices.open/10_basic.yaml @@ -0,0 +1,31 @@ +--- +"Basic test for index open/close": + - do: + indices.create: + index: test_index + + - do: + cluster.health: + wait_for_status: yellow + + - do: + indices.close: + index: test_index + + - do: + catch: forbidden + search: + index: test_index + + - do: + indices.open: + index: test_index + + - do: + cluster.health: + wait_for_status: yellow + + - do: + search: + index: test_index + diff --git a/rest-api-spec/test/indices.open/20_multiple_indices.yaml b/rest-api-spec/test/indices.open/20_multiple_indices.yaml new file mode 100644 index 0000000..8a32cc4 --- /dev/null +++ b/rest-api-spec/test/indices.open/20_multiple_indices.yaml @@ -0,0 +1,83 @@ +setup: + - do: + indices.create: + index: test_index1 + - do: + indices.create: + index: test_index2 + - do: + indices.create: + index: test_index3 + - do: + cluster.health: + wait_for_status: yellow + +--- +"All indices": + - do: + indices.close: + index: _all + + - do: + catch: forbidden + search: + index: test_index2 + + - do: + indices.open: + index: _all + + - do: + cluster.health: + wait_for_status: yellow + + - do: + search: + index: test_index2 + +--- +"Trailing wildcard": + - do: + indices.close: + index: test_* + + - do: + catch: forbidden + search: + index: test_index2 + + - do: + indices.open: + index: test_* + + - do: + cluster.health: + wait_for_status: yellow + + - do: + search: + index: test_index2 + +--- +"Only wildcard": + - do: + indices.close: + index: '*' + + - do: + catch: forbidden + search: + index: test_index3 + + - do: + indices.open: + index: '*' + + - do: + cluster.health: + wait_for_status: yellow + + - do: + search: + index: test_index3 + diff --git a/rest-api-spec/test/indices.optimize/10_basic.yaml b/rest-api-spec/test/indices.optimize/10_basic.yaml new file mode 100644 index 0000000..1f24871 --- /dev/null +++ b/rest-api-spec/test/indices.optimize/10_basic.yaml @@ -0,0 +1,10 @@ +--- +"Optimize index tests": + - do: + indices.create: + index: testing + + - do: + indices.optimize: + index: testing + max_num_segments: 1 diff --git a/rest-api-spec/test/indices.put_alias/10_basic.yaml b/rest-api-spec/test/indices.put_alias/10_basic.yaml new file mode 100644 index 0000000..98fd6b3 --- /dev/null +++ b/rest-api-spec/test/indices.put_alias/10_basic.yaml @@ -0,0 +1,29 @@ +--- +"Basic test for put alias": + + - do: + indices.create: + index: test_index + + - do: + indices.exists_alias: + name: test_alias + + - is_false: '' + + - do: + indices.put_alias: + index: test_index + name: test_alias + + - do: + indices.exists_alias: + name: test_alias + + - is_true: '' + + - do: + indices.get_alias: + name: test_alias + + - match: {test_index.aliases.test_alias: {}} diff --git a/rest-api-spec/test/indices.put_alias/all_path_options.yaml b/rest-api-spec/test/indices.put_alias/all_path_options.yaml new file mode 100644 index 0000000..3392ae3 --- /dev/null +++ b/rest-api-spec/test/indices.put_alias/all_path_options.yaml @@ -0,0 +1,127 @@ +--- +setup: +# create three indices + + - do: + indices.create: + index: test_index1 + - do: + indices.create: + index: test_index2 + - do: + indices.create: + index: foo + +--- +"put alias per index": + + - do: + indices.put_alias: + index: test_index1 + name: alias + - do: + indices.put_alias: + index: test_index2 + name: alias + + - do: + indices.get_alias: + name: alias + + - match: {test_index1.aliases.alias: {}} + + - match: {test_index2.aliases.alias: {}} + + - is_false: foo + +--- +"put alias in _all index": + + - do: + indices.put_alias: + index: _all + name: alias + + - do: + indices.get_alias: + name: alias + + - match: {test_index1.aliases.alias: {}} + - match: {test_index2.aliases.alias: {}} + - match: {foo.aliases.alias: {}} + +--- +"put alias in * index": + + + - do: + indices.put_alias: + index: '*' + name: alias + + - do: + indices.get_alias: + name: alias + + - match: {test_index1.aliases.alias: {}} + - match: {test_index2.aliases.alias: {}} + - match: {foo.aliases.alias: {}} + +--- +"put alias prefix* index": + + + - do: + indices.put_alias: + index: "test_*" + name: alias + + - do: + indices.get_alias: + name: alias + + - match: {test_index1.aliases.alias: {}} + - match: {test_index2.aliases.alias: {}} + - is_false: foo + +--- +"put alias in list of indices": + + + - do: + indices.put_alias: + index: "test_index1,test_index2" + name: alias + + - do: + indices.get_alias: + name: alias + + - match: {test_index1.aliases.alias: {}} + - match: {test_index2.aliases.alias: {}} + - is_false: foo + +--- +"put alias with blank index": + + + - do: + indices.put_alias: + name: alias + + - do: + indices.get_alias: + name: alias + + - match: {test_index1.aliases.alias: {}} + - match: {test_index2.aliases.alias: {}} + - match: {foo.aliases.alias: {}} + +--- +"put alias with missing name": + + + - do: + catch: param + indices.put_alias: {} + diff --git a/rest-api-spec/test/indices.put_mapping/10_basic.yaml b/rest-api-spec/test/indices.put_mapping/10_basic.yaml new file mode 100644 index 0000000..e02b948 --- /dev/null +++ b/rest-api-spec/test/indices.put_mapping/10_basic.yaml @@ -0,0 +1,62 @@ +--- +"Test Create and update mapping": + - do: + indices.create: + index: test_index + + - do: + indices.put_mapping: + index: test_index + type: test_type + body: + test_type: + properties: + text1: + type: string + analyzer: whitespace + text2: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: + index: test_index + + - 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: + index: test_index + type: test_type + body: + test_type: + properties: + text1: + type: multi_field + fields: + text1: + type: string + analyzer: whitespace + text_raw: + type: string + index: not_analyzed + text2: + type: string + analyzer: whitespace + fields: + text_raw: + type: string + index: not_analyzed + + + - do: + indices.get_mapping: + index: test_index + + - 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} diff --git a/rest-api-spec/test/indices.put_mapping/all_path_options.yaml b/rest-api-spec/test/indices.put_mapping/all_path_options.yaml new file mode 100644 index 0000000..23b02f2 --- /dev/null +++ b/rest-api-spec/test/indices.put_mapping/all_path_options.yaml @@ -0,0 +1,178 @@ +setup: + - do: + indices.create: + index: test_index1 + - do: + indices.create: + index: test_index2 + - do: + indices.create: + index: foo + + +--- +"put one mapping per index": + - do: + indices.put_mapping: + index: test_index1 + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + - do: + indices.put_mapping: + index: test_index2 + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.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} + + - is_false: foo + +--- +"put mapping in _all index": + + - do: + indices.put_mapping: + index: _all + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.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.mappings.test_type.properties.text.type: string} + - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + +--- +"put mapping in * index": + - do: + indices.put_mapping: + index: "*" + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.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.mappings.test_type.properties.text.type: string} + - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + +--- +"put mapping in prefix* index": + - do: + indices.put_mapping: + index: "test_index*" + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.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} + + - is_false: foo + +--- +"put mapping in list of indices": + - do: + indices.put_mapping: + index: [test_index1, test_index2] + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.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} + + - is_false: foo + +--- +"put mapping with blank index": + - do: + indices.put_mapping: + type: test_type + body: + test_type: + properties: + text: + type: string + analyzer: whitespace + + - do: + indices.get_mapping: {} + + - match: {test_index1.mappings.test_type.properties.text.type: string} + - match: {test_index1.mappings.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.mappings.test_type.properties.text.type: string} + - match: {foo.mappings.test_type.properties.text.analyzer: whitespace} + +--- +"put mapping with missing type": + + + - do: + catch: param + indices.put_mapping: {} + diff --git a/rest-api-spec/test/indices.put_settings/10_basic.yaml b/rest-api-spec/test/indices.put_settings/10_basic.yaml new file mode 100644 index 0000000..f5b913b --- /dev/null +++ b/rest-api-spec/test/indices.put_settings/10_basic.yaml @@ -0,0 +1,30 @@ +--- +"Test indices settings": + - do: + indices.create: + index: test-index + body: + settings: + index: + number_of_replicas: 0 + + - do: + indices.get_settings: + index: test-index + flat_settings: true + + - match: + test-index.settings.index\.number_of_replicas: "0" + + - do: + indices.put_settings: + body: + number_of_replicas: 1 + + - do: + indices.get_settings: + flat_settings: false + + - match: + test-index.settings.index.number_of_replicas: "1" + diff --git a/rest-api-spec/test/indices.put_settings/all_path_options.yaml b/rest-api-spec/test/indices.put_settings/all_path_options.yaml new file mode 100644 index 0000000..b9ae712 --- /dev/null +++ b/rest-api-spec/test/indices.put_settings/all_path_options.yaml @@ -0,0 +1,113 @@ +setup: + - do: + indices.create: + index: test_index1 + - do: + indices.create: + index: test_index2 + - do: + indices.create: + index: foo + + +--- +"put settings per index": + - do: + indices.put_settings: + index: test_index1 + body: + refresh_interval: 1s + + - do: + indices.put_settings: + index: test_index2 + body: + refresh_interval: 1s + + + - do: + indices.get_settings: {} + + - match: {test_index1.settings.index.refresh_interval: 1s} + - match: {test_index2.settings.index.refresh_interval: 1s} + - is_false: foo.settings.index.refresh_interval + +--- +"put settings in _all index": + - do: + indices.put_settings: + index: _all + body: + refresh_interval: 1s + + - do: + indices.get_settings: {} + + - match: {test_index1.settings.index.refresh_interval: 1s} + - match: {test_index2.settings.index.refresh_interval: 1s} + - match: {foo.settings.index.refresh_interval: 1s} + +--- +"put settings in * index": + - do: + indices.put_settings: + index: '*' + body: + refresh_interval: 1s + + - do: + indices.get_settings: {} + + - match: {test_index1.settings.index.refresh_interval: 1s} + - match: {test_index2.settings.index.refresh_interval: 1s} + - match: {foo.settings.index.refresh_interval: 1s} + + +--- +"put settings in prefix* index": + - do: + indices.put_settings: + index: 'test*' + body: + refresh_interval: 1s + + - do: + indices.get_settings: {} + + - match: {test_index1.settings.index.refresh_interval: 1s} + - match: {test_index2.settings.index.refresh_interval: 1s} + - is_false: foo.settings.index.refresh_interval + +--- +"put settings in list of indices": + - skip: + version: 1 - 999 + reason: list of indices not implemented yet + - do: + indices.put_settings: + index: test_index1, test_index2 + body: + refresh_interval: 1s + + - do: + indices.get_settings: {} + + - match: {test_index1.settings.index.refresh_interval: 1s} + - match: {test_index2.settings.index.refresh_interval: 1s} + - is_false: foo.settings.index.refresh_interval + + +--- +"put settings in blank index": + - do: + indices.put_settings: + body: + refresh_interval: 1s + + - do: + indices.get_settings: {} + + - match: {test_index1.settings.index.refresh_interval: 1s} + - match: {test_index2.settings.index.refresh_interval: 1s} + - match: {foo.settings.index.refresh_interval: 1s} + diff --git a/rest-api-spec/test/indices.put_template/10_basic.yaml b/rest-api-spec/test/indices.put_template/10_basic.yaml new file mode 100644 index 0000000..4c2ab84 --- /dev/null +++ b/rest-api-spec/test/indices.put_template/10_basic.yaml @@ -0,0 +1,17 @@ +--- +"Put template": + - do: + indices.put_template: + name: test + body: + template: test-* + settings: + number_of_shards: 1 + number_of_replicas: 0 + + - do: + indices.get_template: + name: test + + - match: {test.template: "test-*"} + - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}} diff --git a/rest-api-spec/test/indices.put_warmer/10_basic.yaml b/rest-api-spec/test/indices.put_warmer/10_basic.yaml new file mode 100644 index 0000000..44313aa --- /dev/null +++ b/rest-api-spec/test/indices.put_warmer/10_basic.yaml @@ -0,0 +1,145 @@ +--- +setup: + - do: + indices.create: + index: test_index + + - do: + indices.create: + index: test_idx + + - do: + cluster.health: + wait_for_status: yellow + + - do: + indices.put_warmer: + index: test_idx + name: test_warmer2 + body: + query: + match_all: {} + + - do: + indices.put_warmer: + index: test_index + name: test_warmer + body: + query: + match_all: {} + +--- +"Basic test for warmers": + - do: + indices.get_warmer: + index: test_index + name: test_warmer + + - match: {test_index.warmers.test_warmer.source.query.match_all: {}} + + - do: + indices.delete_warmer: + index: test_index + name: test_warmer + + - do: + 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 + diff --git a/rest-api-spec/test/indices.put_warmer/20_aliases.yaml b/rest-api-spec/test/indices.put_warmer/20_aliases.yaml new file mode 100644 index 0000000..96d7344 --- /dev/null +++ b/rest-api-spec/test/indices.put_warmer/20_aliases.yaml @@ -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: {}} + diff --git a/rest-api-spec/test/indices.put_warmer/all_path_options.yaml b/rest-api-spec/test/indices.put_warmer/all_path_options.yaml new file mode 100644 index 0000000..b9c64f7 --- /dev/null +++ b/rest-api-spec/test/indices.put_warmer/all_path_options.yaml @@ -0,0 +1,134 @@ +--- +setup: + + - do: + indices.create: + index: test_index1 + + - do: + indices.create: + index: test_index2 + + - do: + indices.create: + index: foo + + - do: + cluster.health: + wait_for_status: yellow + +--- +"put warmer per index": + + - do: + indices.put_warmer: + index: test_index1 + name: warmer + body: + query: + match_all: {} + - do: + indices.put_warmer: + index: test_index2 + name: warmer + body: + query: + match_all: {} + + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.warmer.source.query.match_all: {}} + - match: {test_index2.warmers.warmer.source.query.match_all: {}} + - is_false: foo + +--- +"put warmer in _all index": + - do: + indices.put_warmer: + index: _all + name: warmer + body: + query: + match_all: {} + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.warmer.source.query.match_all: {}} + - match: {test_index2.warmers.warmer.source.query.match_all: {}} + - match: {foo.warmers.warmer.source.query.match_all: {}} + +--- +"put warmer in * index": + - do: + indices.put_warmer: + index: "*" + name: warmer + body: + query: + match_all: {} + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.warmer.source.query.match_all: {}} + - match: {test_index2.warmers.warmer.source.query.match_all: {}} + - match: {foo.warmers.warmer.source.query.match_all: {}} + +--- +"put warmer prefix* index": + - do: + indices.put_warmer: + index: "test_index*" + name: warmer + body: + query: + match_all: {} + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.warmer.source.query.match_all: {}} + - match: {test_index2.warmers.warmer.source.query.match_all: {}} + - is_false: foo + +--- +"put warmer in list of indices": + - do: + indices.put_warmer: + index: [test_index1, test_index2] + name: warmer + body: + query: + match_all: {} + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.warmer.source.query.match_all: {}} + - match: {test_index2.warmers.warmer.source.query.match_all: {}} + - is_false: foo + +--- +"put warmer with blank index": + - do: + indices.put_warmer: + name: warmer + body: + query: + match_all: {} + - do: + indices.get_warmer: { index: _all, name: '*' } + + - match: {test_index1.warmers.warmer.source.query.match_all: {}} + - match: {test_index2.warmers.warmer.source.query.match_all: {}} + - match: {foo.warmers.warmer.source.query.match_all: {}} + +--- +"put warmer with missing name": + + + - do: + catch: param + indices.put_warmer: + body: + query: + match_all: {} + diff --git a/rest-api-spec/test/indices.segments/10_basic.yaml b/rest-api-spec/test/indices.segments/10_basic.yaml new file mode 100644 index 0000000..801982e --- /dev/null +++ b/rest-api-spec/test/indices.segments/10_basic.yaml @@ -0,0 +1,5 @@ +--- +"segments test": + - do: + indices.segments: + allow_no_indices: true diff --git a/rest-api-spec/test/indices.snapshot_index/10_basic.yaml b/rest-api-spec/test/indices.snapshot_index/10_basic.yaml new file mode 100644 index 0000000..7acd47f --- /dev/null +++ b/rest-api-spec/test/indices.snapshot_index/10_basic.yaml @@ -0,0 +1,4 @@ +--- +"snapshot_index test": + - do: + indices.snapshot_index: {} diff --git a/rest-api-spec/test/indices.stats/10_basic.yaml b/rest-api-spec/test/indices.stats/10_basic.yaml new file mode 100644 index 0000000..f197f38 --- /dev/null +++ b/rest-api-spec/test/indices.stats/10_basic.yaml @@ -0,0 +1,4 @@ +--- +"stats test": + - do: + indices.stats: {} diff --git a/rest-api-spec/test/indices.status/10_basic.yaml b/rest-api-spec/test/indices.status/10_basic.yaml new file mode 100644 index 0000000..89f4ae5 --- /dev/null +++ b/rest-api-spec/test/indices.status/10_basic.yaml @@ -0,0 +1,9 @@ +--- +"Indices status test": + - do: + indices.status: {} + + - do: + catch: missing + indices.status: + index: not_here diff --git a/rest-api-spec/test/indices.update_aliases/10_basic.yaml b/rest-api-spec/test/indices.update_aliases/10_basic.yaml new file mode 100644 index 0000000..5b45f74 --- /dev/null +++ b/rest-api-spec/test/indices.update_aliases/10_basic.yaml @@ -0,0 +1,34 @@ +--- +"Basic test for aliases": + + - do: + indices.create: + index: test_index + + - do: + indices.exists_alias: + name: test_alias + + - is_false: '' + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + routing: routing_value + + - do: + indices.exists_alias: + name: test_alias + + - is_true: '' + + - do: + indices.get_alias: + index: test_index + name: test_alias + + - match: {test_index.aliases.test_alias: {'index_routing': 'routing_value', 'search_routing': 'routing_value'}} diff --git a/rest-api-spec/test/indices.update_aliases/20_routing.yaml b/rest-api-spec/test/indices.update_aliases/20_routing.yaml new file mode 100644 index 0000000..197de05 --- /dev/null +++ b/rest-api-spec/test/indices.update_aliases/20_routing.yaml @@ -0,0 +1,135 @@ +setup: + - do: + indices.create: + index: test_index + +--- +"Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + routing: routing + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'index_routing': 'routing', 'search_routing': 'routing'}} + +--- +"Index Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + index_routing: index_routing + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'index_routing': 'index_routing'}} + +--- +"Search Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + search_routing: search_routing + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'search_routing': 'search_routing'}} + +--- +"Index, Default Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + index_routing: index_routing + routing: routing + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'index_routing': 'index_routing', 'search_routing': 'routing'}} + +--- +"Search, Default Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + search_routing: search_routing + routing: routing + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'index_routing': 'routing', 'search_routing': 'search_routing'}} + +--- +"Index, Search, Default Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + index_routing: index_routing + search_routing: search_routing + routing: routing + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'index_routing': 'index_routing', 'search_routing': 'search_routing'}} + +--- +"Numeric Routing": + + - do: + indices.update_aliases: + body: + actions: + - add: + index: test_index + alias: test_alias + routing: 5 + + - do: + indices.get_aliases: + index: test_index + + - match: {test_index.aliases.test_alias: {'index_routing': '5', 'search_routing': '5'}} + diff --git a/rest-api-spec/test/indices.validate_query/10_basic.yaml b/rest-api-spec/test/indices.validate_query/10_basic.yaml new file mode 100644 index 0000000..1325eaa --- /dev/null +++ b/rest-api-spec/test/indices.validate_query/10_basic.yaml @@ -0,0 +1,27 @@ +--- +"Validate query api": + - do: + indices.create: + index: testing + body: + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: yellow + + - do: + indices.validate_query: + q: query string + + - is_true: valid + + - do: + indices.validate_query: + body: + query: + invalid_query: {} + + - is_false: valid + diff --git a/rest-api-spec/test/info/10_info.yaml b/rest-api-spec/test/info/10_info.yaml new file mode 100644 index 0000000..62301d8 --- /dev/null +++ b/rest-api-spec/test/info/10_info.yaml @@ -0,0 +1,8 @@ +--- +"Info": + - do: {info: {}} + - match: {status: 200} + - is_true: name + - is_true: tagline + - is_true: version + - is_true: version.number diff --git a/rest-api-spec/test/info/20_lucene_version.yaml b/rest-api-spec/test/info/20_lucene_version.yaml new file mode 100644 index 0000000..e67bc80 --- /dev/null +++ b/rest-api-spec/test/info/20_lucene_version.yaml @@ -0,0 +1,8 @@ +--- +"Lucene Version": + - do: {info: {}} + - match: {status: 200} + - is_true: version.lucene_version + + + diff --git a/rest-api-spec/test/mget/10_basic.yaml b/rest-api-spec/test/mget/10_basic.yaml new file mode 100644 index 0000000..0850772 --- /dev/null +++ b/rest-api-spec/test/mget/10_basic.yaml @@ -0,0 +1,45 @@ +--- +"Basic multi-get": + - do: + indices.create: + index: test_2 + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + indices.refresh: {} + + - do: + mget: + body: + docs: + - { _index: test_2, _type: test, _id: 1} + - { _index: test_1, _type: none, _id: 1} + - { _index: test_1, _type: test, _id: 2} + - { _index: test_1, _type: test, _id: 1} + + - is_false: docs.0.found + - match: { docs.0._index: test_2 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + + - is_false: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: none } + - match: { docs.1._id: "1" } + + - is_false: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "2" } + + - is_true: docs.3.found + - match: { docs.3._index: test_1 } + - match: { docs.3._type: test } + - match: { docs.3._id: "1" } + - match: { docs.3._version: 1 } + - match: { docs.3._source: { foo: bar }} diff --git a/rest-api-spec/test/mget/11_default_index_type.yaml b/rest-api-spec/test/mget/11_default_index_type.yaml new file mode 100644 index 0000000..b556cf9 --- /dev/null +++ b/rest-api-spec/test/mget/11_default_index_type.yaml @@ -0,0 +1,48 @@ +--- +"Default index/type": + - do: + indices.create: + index: test_2 + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + cluster.health: + wait_for_status: yellow + + - do: + mget: + index: test_1 + type: test + body: + docs: + - { _index: test_2, _id: 1} + - { _type: none, _id: 1} + - { _id: 2} + - { _id: 1} + + - is_false: docs.0.found + - match: { docs.0._index: test_2 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + + - is_false: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: none } + - match: { docs.1._id: "1" } + + - is_false: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "2" } + + - is_true: docs.3.found + - match: { docs.3._index: test_1 } + - match: { docs.3._type: test } + - match: { docs.3._id: "1" } + - match: { docs.3._version: 1 } + - match: { docs.3._source: { foo: bar }} diff --git a/rest-api-spec/test/mget/12_non_existent_index.yaml b/rest-api-spec/test/mget/12_non_existent_index.yaml new file mode 100644 index 0000000..f91f323 --- /dev/null +++ b/rest-api-spec/test/mget/12_non_existent_index.yaml @@ -0,0 +1,35 @@ +--- +"Non-existent index": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + cluster.health: + wait_for_status: yellow + + - do: + mget: + body: + docs: + - { _index: test_2, _type: test, _id: 1} + + - is_false: docs.0.found + - match: { docs.0._index: test_2 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + + - do: + mget: + body: + index: test_2 + docs: + - { _index: test_1, _type: test, _id: 1} + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } diff --git a/rest-api-spec/test/mget/13_missing_metadata.yaml b/rest-api-spec/test/mget/13_missing_metadata.yaml new file mode 100644 index 0000000..11b4a12 --- /dev/null +++ b/rest-api-spec/test/mget/13_missing_metadata.yaml @@ -0,0 +1,51 @@ +--- +"Missing metadata": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + cluster.health: + wait_for_status: yellow + + - do: + catch: /ActionRequestValidationException.+ id is missing/ + mget: + body: + docs: + - { _index: test_1, _type: test} + + - do: + catch: /ActionRequestValidationException.+ index is missing/ + mget: + body: + docs: + - { _type: test, _id: 1} + + - do: + catch: /ActionRequestValidationException.+ no documents to get/ + mget: + body: + docs: [] + + - do: + catch: /ActionRequestValidationException.+ no documents to get/ + mget: + body: {} + + - do: + mget: + body: + docs: + - { _index: test_1, _id: 1} + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + - match: { docs.0._version: 1 } + - match: { docs.0._source: { foo: bar }} diff --git a/rest-api-spec/test/mget/15_ids.yaml b/rest-api-spec/test/mget/15_ids.yaml new file mode 100644 index 0000000..a86fc2c --- /dev/null +++ b/rest-api-spec/test/mget/15_ids.yaml @@ -0,0 +1,72 @@ +--- +"IDs": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test_2 + id: 2 + body: { foo: baz } + + - do: + cluster.health: + wait_for_status: yellow + + - do: + mget: + index: test_1 + type: test + body: + ids: [1, 2] + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + - match: { docs.0._version: 1 } + - match: { docs.0._source: { foo: bar }} + + - is_false: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: test } + - match: { docs.1._id: "2" } + + - do: + mget: + index: test_1 + body: + ids: [1, 2] + + - is_true: docs.0.found + - match: { docs.0._index: test_1 } + - match: { docs.0._type: test } + - match: { docs.0._id: "1" } + - match: { docs.0._version: 1 } + - match: { docs.0._source: { foo: bar }} + + - is_true: docs.1.found + - match: { docs.1._index: test_1 } + - match: { docs.1._type: test_2 } + - match: { docs.1._id: "2" } + - match: { docs.1._version: 1 } + - match: { docs.1._source: { foo: baz }} + + + - do: + catch: /ActionRequestValidationException.+ no documents to get/ + mget: + index: test_1 + body: + ids: [] + + - do: + catch: /ActionRequestValidationException.+ no documents to get/ + mget: + index: test_1 + body: {} diff --git a/rest-api-spec/test/mget/20_fields.yaml b/rest-api-spec/test/mget/20_fields.yaml new file mode 100644 index 0000000..347fc25 --- /dev/null +++ b/rest-api-spec/test/mget/20_fields.yaml @@ -0,0 +1,109 @@ +--- +"Fields": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + cluster.health: + wait_for_status: yellow + + - do: + mget: + index: test_1 + type: test + body: + docs: + - { _id: 1 } + - { _id: 1, fields: foo } + - { _id: 1, fields: [foo] } + - { _id: 1, fields: [foo, _source] } + + - is_false: docs.0.fields + - match: { docs.0._source: { foo: bar }} + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + + - do: + mget: + index: test_1 + type: test + fields: foo + body: + docs: + - { _id: 1 } + - { _id: 1, fields: foo } + - { _id: 1, fields: [foo] } + - { _id: 1, fields: [foo, _source] } + + - match: { docs.0.fields.foo: [bar] } + - is_false: docs.0._source + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + + - do: + mget: + index: test_1 + type: test + fields: [foo] + body: + docs: + - { _id: 1 } + - { _id: 1, fields: foo } + - { _id: 1, fields: [foo] } + - { _id: 1, fields: [foo, _source] } + + - match: { docs.0.fields.foo: [bar] } + - is_false: docs.0._source + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + + - do: + mget: + index: test_1 + type: test + fields: [foo, _source] + body: + docs: + - { _id: 1 } + - { _id: 1, fields: foo } + - { _id: 1, fields: [foo] } + - { _id: 1, fields: [foo, _source] } + + - match: { docs.0.fields.foo: [bar] } + - match: { docs.0._source: { foo: bar }} + + - match: { docs.1.fields.foo: [bar] } + - is_false: docs.1._source + + - match: { docs.2.fields.foo: [bar] } + - is_false: docs.2._source + + - match: { docs.3.fields.foo: [bar] } + - match: { docs.3._source: { foo: bar }} + diff --git a/rest-api-spec/test/mget/30_parent.yaml b/rest-api-spec/test/mget/30_parent.yaml new file mode 100644 index 0000000..491b8b8 --- /dev/null +++ b/rest-api-spec/test/mget/30_parent.yaml @@ -0,0 +1,57 @@ +--- +"Parent": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 4 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 2 + parent: 5 + body: { foo: bar } + + - do: + mget: + index: test_1 + type: test + body: + docs: + - { _id: 1 } + - { _id: 1, parent: 5, fields: [ _parent, _routing ] } + - { _id: 1, parent: 4, fields: [ _parent, _routing ] } + - { _id: 2, parent: 5, fields: [ _parent, _routing ] } + + - is_false: docs.0.found + - is_false: docs.1.found + + - is_true: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "1" } + - match: { docs.2.fields._parent: "4" } + - match: { docs.2.fields._routing: "4" } + + - is_true: docs.3.found + - match: { docs.3._index: test_1 } + - match: { docs.3._type: test } + - match: { docs.3._id: "2" } + - match: { docs.3.fields._parent: "5" } + - match: { docs.3.fields._routing: "5" } diff --git a/rest-api-spec/test/mget/40_routing.yaml b/rest-api-spec/test/mget/40_routing.yaml new file mode 100644 index 0000000..96734da --- /dev/null +++ b/rest-api-spec/test/mget/40_routing.yaml @@ -0,0 +1,42 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + routing: 5 + body: { foo: bar } + + - do: + mget: + index: test_1 + type: test + fields: [_routing] + body: + docs: + - { _id: 1 } + - { _id: 1, routing: 4 } + - { _id: 1, routing: 5 } + + - is_false: docs.0.found + - is_false: docs.1.found + + - is_true: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "1" } + - match: { docs.2.fields._routing: "5" } diff --git a/rest-api-spec/test/mget/55_parent_with_routing.yaml b/rest-api-spec/test/mget/55_parent_with_routing.yaml new file mode 100644 index 0000000..039f5c5 --- /dev/null +++ b/rest-api-spec/test/mget/55_parent_with_routing.yaml @@ -0,0 +1,46 @@ +--- +"Parent": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 4 + routing: 5 + body: { foo: bar } + + - do: + mget: + index: test_1 + type: test + fields: [ _routing , _parent] + body: + docs: + - { _id: 1 } + - { _id: 1, parent: 4 } + - { _id: 1, parent: 4, routing: 5 } + + - is_false: docs.0.found + - is_false: docs.1.found + + - is_true: docs.2.found + - match: { docs.2._index: test_1 } + - match: { docs.2._type: test } + - match: { docs.2._id: "1" } + - match: { docs.2.fields._parent: "4" } + - match: { docs.2.fields._routing: "5" } diff --git a/rest-api-spec/test/mget/60_realtime_refresh.yaml b/rest-api-spec/test/mget/60_realtime_refresh.yaml new file mode 100644 index 0000000..c688b4b --- /dev/null +++ b/rest-api-spec/test/mget/60_realtime_refresh.yaml @@ -0,0 +1,53 @@ +--- +"Realtime Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + refresh_interval: -1 + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + mget: + index: test_1 + type: test + realtime: 0 + body: + ids: [1] + + - is_false: docs.0.found + + - do: + mget: + index: test_1 + type: test + realtime: 1 + body: + ids: [1] + + - is_true: docs.0.found + + - do: + mget: + index: test_1 + type: test + realtime: 0 + refresh: 1 + body: + ids: [1] + + - is_true: docs.0.found diff --git a/rest-api-spec/test/mget/70_source_filtering.yaml b/rest-api-spec/test/mget/70_source_filtering.yaml new file mode 100644 index 0000000..a1c16b3 --- /dev/null +++ b/rest-api-spec/test/mget/70_source_filtering.yaml @@ -0,0 +1,119 @@ +setup: + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + - do: + index: + index: test_1 + type: test + id: 2 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + +--- +"Source filtering - true/false": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: false } + - { _index: "test_1", _type: "test", _id: "2", _source: true } + + - match: { docs.0._id: "1" } + - is_false: docs.0._source + - match: { docs.1._id: "2" } + - is_true: docs.1._source + +--- +"Source filtering - include field": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: include.field1 } + - { _index: "test_1", _type: "test", _id: "2", _source: [ include.field1 ] } + + - match: { docs.0._source: { include: { field1: v1 }} } + - match: { docs.1._source: { include: { field1: v1 }} } + + +--- +"Source filtering - include nested field": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: { include: include.field1 } } + - { _index: "test_1", _type: "test", _id: "2", _source: { include: [ include.field1 ] } } + + - match: { docs.0._source: { include: { field1: v1 }} } + - match: { docs.1._source: { include: { field1: v1 }} } + +--- +"Source filtering - exclude field": + + - do: + mget: + body: + docs: + - { _index: "test_1", _type: "test", _id: "1", _source: { include: [ include ], exclude: [ "*.field2" ] } } + + - match: { docs.0._source: { include: { field1: v1 }} } + +--- +"Source filtering - ids and true/false": + + - do: + mget: + _source: false + index: test_1 + body: { ids: [ 1,2 ] } + - is_false: docs.0._source + - is_false: docs.1._source + + - do: + mget: + _source: true + index: test_1 + body: { ids: [ 1,2 ] } + - is_true: docs.0._source + - is_true: docs.1._source + +--- +"Source filtering - ids and include field": + + - do: + mget: + _source: include.field1 + index: test_1 + body: { ids: [ 1,2 ] } + - match: { docs.0._source: { include: { field1: v1 }} } + - match: { docs.1._source: { include: { field1: v1 }} } + +--- +"Source filtering - ids and include nested field": + + - do: + mget: + _source_include: "include.field1,count" + index: test_1 + body: { ids: [ 1,2 ] } + - match: { docs.0._source: { include: { field1: v1 }, count: 1} } + - match: { docs.1._source: { include: { field1: v1 }, count: 1} } + +--- +"Source filtering - ids and exclude field": + + - do: + mget: + _source_include: include + _source_exclude: "*.field2" + index: test_1 + body: { ids: [ 1,2 ] } + - match: { docs.0._source: { include: { field1: v1 } } } + - match: { docs.1._source: { include: { field1: v1 } } } diff --git a/rest-api-spec/test/mget/TODO.txt b/rest-api-spec/test/mget/TODO.txt new file mode 100644 index 0000000..340ff57 --- /dev/null +++ b/rest-api-spec/test/mget/TODO.txt @@ -0,0 +1,3 @@ +Tests missing for: + +# preference diff --git a/rest-api-spec/test/mlt/10_basic.yaml b/rest-api-spec/test/mlt/10_basic.yaml new file mode 100644 index 0000000..e914607 --- /dev/null +++ b/rest-api-spec/test/mlt/10_basic.yaml @@ -0,0 +1,25 @@ +--- +"Basic mlt": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar, title: howdy } + + - do: + indices.refresh: {} + + - do: + cluster.health: + wait_for_status: green + timeout: 1s + - do: + mlt: + index: test_1 + type: test + id: 1 + mlt_fields: title + + - match: {hits.total: 0} + diff --git a/rest-api-spec/test/mpercolate/10_basic.yaml b/rest-api-spec/test/mpercolate/10_basic.yaml new file mode 100644 index 0000000..70118c9 --- /dev/null +++ b/rest-api-spec/test/mpercolate/10_basic.yaml @@ -0,0 +1,41 @@ +--- +"Basic multi-percolate": + - do: + index: + index: percolator_index + type: my_type + id: 1 + body: {foo: bar} + + - do: + index: + index: percolator_index + type: .percolator + id: test_percolator + body: + query: + match_all: {} + + - do: + mpercolate: + body: + - percolate: + index: percolator_index + type: my_type + - doc: + foo: bar + - percolate: + index: percolator_index1 + type: my_type + - doc: + foo: bar + - percolate: + index: percolator_index + type: my_type + id: 1 + - doc: + foo: bar + + - match: { responses.0.total: 1 } + - match: { responses.1.error: "IndexMissingException[[percolator_index1] missing]" } + - match: { responses.2.total: 1 } diff --git a/rest-api-spec/test/msearch/10_basic.yaml b/rest-api-spec/test/msearch/10_basic.yaml new file mode 100644 index 0000000..ce6bc17 --- /dev/null +++ b/rest-api-spec/test/msearch/10_basic.yaml @@ -0,0 +1,45 @@ +--- +"Basic multi-search": + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_1 + type: test + id: 2 + body: { foo: baz } + + - do: + index: + index: test_1 + type: test + id: 3 + body: { foo: foo } + + - do: + indices.refresh: {} + + - do: + msearch: + body: + - index: test_1 + - query: + match_all: {} + - index: test_2 + - query: + match_all: {} + - search_type: count + index: test_1 + - query: + match: {foo: bar} + + - match: { responses.0.hits.total: 3 } + - match: { responses.1.error: "IndexMissingException[[test_2] missing]" } + - match: { responses.2.hits.total: 1 } + + diff --git a/rest-api-spec/test/mtermvectors/10_basic.yaml b/rest-api-spec/test/mtermvectors/10_basic.yaml new file mode 100644 index 0000000..53005b0 --- /dev/null +++ b/rest-api-spec/test/mtermvectors/10_basic.yaml @@ -0,0 +1,85 @@ +setup: + - do: + indices.create: + index: testidx + body: + mappings: + testtype: + properties: + text: + type : "string" + term_vector : "with_positions_offsets" + - do: + index: + index: testidx + type: testtype + id: testing_document + body: {"text" : "The quick brown fox is brown."} + + - do: + indices.refresh: {} + +--- +"Basic tests for multi termvector get": + + - do: + mtermvectors: + "term_statistics" : true + "body" : + "docs": + - + "_index" : "testidx" + "_type" : "testtype" + "_id" : "testing_document" + + - match: {docs.0.term_vectors.text.terms.brown.term_freq: 2} + - match: {docs.0.term_vectors.text.terms.brown.ttf: 2} + + - do: + mtermvectors: + "term_statistics" : true + "body" : + "docs": + - + "_index" : "testidx" + "_type" : "testtype" + "_id" : "testing_document" + + - match: {docs.0.term_vectors.text.terms.brown.term_freq: 2} + - match: {docs.0.term_vectors.text.terms.brown.ttf: 2} + + - do: + mtermvectors: + "term_statistics" : true + "index" : "testidx" + "body" : + "docs": + - + "_type" : "testtype" + "_id" : "testing_document" + + - match: {docs.0.term_vectors.text.terms.brown.term_freq: 2} + - match: {docs.0.term_vectors.text.terms.brown.ttf: 2} + + - do: + mtermvectors: + "term_statistics" : true + "index" : "testidx" + "type" : "testtype" + "body" : + "docs": + - + "_id" : "testing_document" + + - match: {docs.0.term_vectors.text.terms.brown.term_freq: 2} + - match: {docs.0.term_vectors.text.terms.brown.ttf: 2} + + - do: + mtermvectors: + "term_statistics" : true + "index" : "testidx" + "type" : "testtype" + "ids" : ["testing_document"] + + - match: {docs.0.term_vectors.text.terms.brown.term_freq: 2} + - match: {docs.0.term_vectors.text.terms.brown.ttf: 2} diff --git a/rest-api-spec/test/nodes.info/10_basic.yaml b/rest-api-spec/test/nodes.info/10_basic.yaml new file mode 100644 index 0000000..cf632c5 --- /dev/null +++ b/rest-api-spec/test/nodes.info/10_basic.yaml @@ -0,0 +1,7 @@ +--- +"node_info test": + - do: + nodes.info: {} + + - is_true: nodes + - is_true: cluster_name diff --git a/rest-api-spec/test/nodes.stats/10_basic.yaml b/rest-api-spec/test/nodes.stats/10_basic.yaml new file mode 100644 index 0000000..977d002 --- /dev/null +++ b/rest-api-spec/test/nodes.stats/10_basic.yaml @@ -0,0 +1,8 @@ +--- +"Nodes stats": + - do: + nodes.stats: + metric: [ indices, transport ] + + - is_true: cluster_name + - is_true: nodes diff --git a/rest-api-spec/test/percolate/15_new.yaml b/rest-api-spec/test/percolate/15_new.yaml new file mode 100644 index 0000000..63c5b9a --- /dev/null +++ b/rest-api-spec/test/percolate/15_new.yaml @@ -0,0 +1,40 @@ +--- +"Basic percolation tests": + + - do: + indices.create: + index: test_index + + - do: + index: + index: test_index + type: .percolator + id: test_percolator + body: + query: + match_all: {} + + - do: + indices.refresh: {} + + - do: + percolate: + index: test_index + type: test_type + body: + doc: + foo: bar + + - match: {'total': 1} + - match: {'matches': [{_index: test_index, _id: test_percolator}]} + + - do: + count_percolate: + index: test_index + type: test_type + body: + doc: + foo: bar + + - is_false: matches + - match: {'total': 1} diff --git a/rest-api-spec/test/percolate/16_existing_doc.yaml b/rest-api-spec/test/percolate/16_existing_doc.yaml new file mode 100644 index 0000000..a539b0f --- /dev/null +++ b/rest-api-spec/test/percolate/16_existing_doc.yaml @@ -0,0 +1,86 @@ +--- +"Percolate existing documents": + + - do: + indices.create: + index: percolator_index + + - do: + index: + index: percolator_index + type: .percolator + id: test_percolator + body: + query: + match_all: {} + + - do: + index: + index: percolator_index + type: test_type + id: 1 + body: + foo: bar + + - do: + indices.create: + index: my_index + + - do: + index: + index: my_index + type: my_type + id: 1 + body: + foo: bar + + - do: + indices.refresh: {} + + - do: + percolate: + index: percolator_index + type: test_type + id: 1 + + - match: {'matches': [{_index: percolator_index, _id: test_percolator}]} + + - do: + percolate: + index: my_index + type: my_type + id: 1 + percolate_index: percolator_index + percolate_type: test_type + + - match: {'matches': [{_index: percolator_index, _id: test_percolator}]} + + + - do: + index: + index: my_index + type: my_type + id: 1 + body: + foo: bar + + - do: + percolate: + index: my_index + type: my_type + id: 1 + version: 2 + percolate_index: percolator_index + percolate_type: test_type + + - match: {'matches': [{_index: percolator_index, _id: test_percolator}]} + + - do: + catch: conflict + percolate: + index: my_index + type: my_type + id: 1 + version: 1 + percolate_index: percolator_index + percolate_type: test_type diff --git a/rest-api-spec/test/percolate/17_empty.yaml b/rest-api-spec/test/percolate/17_empty.yaml new file mode 100644 index 0000000..0cd1ac5 --- /dev/null +++ b/rest-api-spec/test/percolate/17_empty.yaml @@ -0,0 +1,31 @@ +--- +"Basic percolation tests on an empty cluster": + + - do: + indices.create: + index: test_index + + - do: + indices.refresh: {} + + - do: + percolate: + index: test_index + type: test_type + body: + doc: + foo: bar + + - match: {'total': 0} + - match: {'matches': []} + + - do: + count_percolate: + index: test_index + type: test_type + body: + doc: + foo: bar + + - is_false: matches + - match: {'total': 0} diff --git a/rest-api-spec/test/percolate/18_highligh_with_query.yaml b/rest-api-spec/test/percolate/18_highligh_with_query.yaml new file mode 100644 index 0000000..c02996b --- /dev/null +++ b/rest-api-spec/test/percolate/18_highligh_with_query.yaml @@ -0,0 +1,36 @@ +--- +"Basic percolation highlight query test": + + - do: + indices.create: + index: test_index + + - do: + index: + index: test_index + type: .percolator + id: test_percolator + body: + query: + match: + foo: bar + + - do: + indices.refresh: {} + + - do: + percolate: + index: test_index + type: test_type + body: + doc: + foo: "bar foo" + size: 1 + highlight: + fields: + foo: + highlight_query: + match: + foo: foo + + - match: {'total': 1} diff --git a/rest-api-spec/test/ping/10_ping.yaml b/rest-api-spec/test/ping/10_ping.yaml new file mode 100644 index 0000000..ec07c21 --- /dev/null +++ b/rest-api-spec/test/ping/10_ping.yaml @@ -0,0 +1,5 @@ +--- +"Ping": + - do: { ping: {}} + - is_true: '' + diff --git a/rest-api-spec/test/scroll/10_basic.yaml b/rest-api-spec/test/scroll/10_basic.yaml new file mode 100644 index 0000000..3dbca74 --- /dev/null +++ b/rest-api-spec/test/scroll/10_basic.yaml @@ -0,0 +1,32 @@ +--- +"Basic scroll": + - do: + indices.create: + index: test_scroll + - do: + index: + index: test_scroll + type: test + id: 42 + body: { foo: bar } + + - do: + indices.refresh: {} + + - do: + search: + index: test_scroll + search_type: scan + scroll: 1m + body: + query: + match_all: {} + + - set: {_scroll_id: scroll_id} + + - do: + scroll: + scroll_id: $scroll_id + + - match: {hits.total: 1 } + - match: {hits.hits.0._id: "42" } diff --git a/rest-api-spec/test/scroll/11_clear.yaml b/rest-api-spec/test/scroll/11_clear.yaml new file mode 100644 index 0000000..30b7e18 --- /dev/null +++ b/rest-api-spec/test/scroll/11_clear.yaml @@ -0,0 +1,34 @@ +--- +"Clear scroll": + - do: + indices.create: + index: test_scroll + - do: + index: + index: test_scroll + type: test + id: 42 + body: { foo: bar } + + - do: + indices.refresh: {} + + - do: + search: + index: test_scroll + search_type: scan + scroll: 1m + body: + query: + match_all: {} + + - set: {_scroll_id: scroll_id1} + + - do: + clear_scroll: + scroll_id: $scroll_id1 + + - do: + catch: request + scroll: + scroll_id: $scroll_id1 diff --git a/rest-api-spec/test/search/10_source_filtering.yaml b/rest-api-spec/test/search/10_source_filtering.yaml new file mode 100644 index 0000000..40a67ba --- /dev/null +++ b/rest-api-spec/test/search/10_source_filtering.yaml @@ -0,0 +1,92 @@ +--- +"Source filtering": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "include": { "field1": "v1", "field2": "v2" }, "count": 1 } + - do: + indices.refresh: {} + + + - do: + search: + # stringified for boolean value + body: "{ _source: true, query: { match_all: {} } }" + + - length: { hits.hits: 1 } + - match: { hits.hits.0._source.count: 1 } + + - do: { search: { body: "{ _source: false, query: { match_all: {} } }" } } + - length: { hits.hits: 1 } + - is_false: hits.hits.0._source + + - do: { search: { body: { query: { match_all: {} } } } } + - length: { hits.hits: 1 } + - match: { hits.hits.0._source.count: 1 } + + - do: { search: { body: { _source: include.field1, query: { match_all: {} } } } } + - match: { hits.hits.0._source.include.field1: v1 } + - is_false: hits.hits.0._source.include.field2 + + - do: { search: { _source_include: include.field1, body: { _source: include.field2, query: { match_all: {} } } } } + - match: { hits.hits.0._source.include.field1: v1 } + - is_false: hits.hits.0._source.include.field2 + + - do: { search: { _source_include: include.field1, body: { query: { match_all: {} } } } } + - match: { hits.hits.0._source.include.field1: v1 } + - is_false: hits.hits.0._source.include.field2 + + - do: { search: { _source_exclude: count, body: { query: { match_all: {} } } } } + - match: { hits.hits.0._source.include: { field1 : v1 , field2: v2 }} + - is_false: hits.hits.0._source.count + + + - do: + search: + body: + _source: [ include.field1, include.field2 ] + query: { match_all: {} } + - match: { hits.hits.0._source.include.field1: v1 } + - match: { hits.hits.0._source.include.field2: v2 } + - is_false: hits.hits.0._source.count + + - do: + search: + body: + _source: + include: [ include.field1, include.field2 ] + query: { match_all: {} } + - match: { hits.hits.0._source.include.field1: v1 } + - match: { hits.hits.0._source.include.field2: v2 } + - is_false: hits.hits.0._source.count + + - do: + search: + body: + _source: + includes: include + excludes: "*.field2" + query: { match_all: {} } + - match: { hits.hits.0._source.include.field1: v1 } + - is_false: hits.hits.0._source.include.field2 + + + - do: + search: + body: + fields: [ include.field2 ] + query: { match_all: {} } + - match: { hits.hits.0.fields: { include.field2 : [v2] }} + - is_false: hits.hits.0._source + + - do: + search: + body: + fields: [ include.field2, _source ] + query: { match_all: {} } + - match: { hits.hits.0.fields: { include.field2 : [v2] }} + - is_true: hits.hits.0._source + diff --git a/rest-api-spec/test/search/20_default_values.yaml b/rest-api-spec/test/search/20_default_values.yaml new file mode 100644 index 0000000..e8f1434 --- /dev/null +++ b/rest-api-spec/test/search/20_default_values.yaml @@ -0,0 +1,43 @@ +--- +"Default index": + - do: + indices.create: + index: test_2 + - do: + indices.create: + index: test_1 + - do: + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + + - do: + index: + index: test_2 + type: test + id: 42 + body: { foo: bar } + + - do: + indices.refresh: + index: [test_1, test_2] + + - do: + search: + index: _all + type: test + body: + query: + match: + foo: bar + + - match: {hits.total: 2} + - match: {hits.hits.0._index: test_1 } + - match: {hits.hits.0._type: test } + - match: {hits.hits.0._id: "1" } + + - match: {hits.hits.1._index: test_2 } + - match: {hits.hits.1._type: test } + - match: {hits.hits.1._id: "42" } diff --git a/rest-api-spec/test/snapshot.get_repository/10_basic.yaml b/rest-api-spec/test/snapshot.get_repository/10_basic.yaml new file mode 100644 index 0000000..1bb2fa0 --- /dev/null +++ b/rest-api-spec/test/snapshot.get_repository/10_basic.yaml @@ -0,0 +1,50 @@ +--- +setup: + + - do: + snapshot.create_repository: + repository: test_repo1 + body: + type: url + settings: + url: "http://snapshot.test1" + + - do: + snapshot.create_repository: + repository: test_repo2 + body: + type: url + settings: + url: "http://snapshot.test2" + +--- +"Get all repositories": + - do: + snapshot.get_repository: {} + + - is_true: test_repo1 + - is_true: test_repo2 + +--- +"Get repository by name": + - do: + snapshot.get_repository: + repository: test_repo1 + + - is_true: test_repo1 + - is_false: test_repo2 + +--- +"Get missing repository by name": + - do: + snapshot.get_repository: + repository: test_repo2 + +--- +"Get all repositories with local flag": + - do: + snapshot.get_repository: + local: true + + - is_true: test_repo1 + - is_true: test_repo2 diff --git a/rest-api-spec/test/suggest/10_basic.yaml b/rest-api-spec/test/suggest/10_basic.yaml new file mode 100644 index 0000000..211e95b --- /dev/null +++ b/rest-api-spec/test/suggest/10_basic.yaml @@ -0,0 +1,24 @@ +setup: + - do: + index: + index: test + type: test + id: testing_document + body: + body: Amsterdam meetup + - do: + indices.refresh: {} + +--- +"Basic tests for suggest API": + + - do: + suggest: + body: + test_suggestion: + text: "The Amsterdma meetpu" + term: + field: body + + - match: {test_suggestion.1.options.0.text: amsterdam} + - match: {test_suggestion.2.options.0.text: meetup} diff --git a/rest-api-spec/test/termvector/10_basic.yaml b/rest-api-spec/test/termvector/10_basic.yaml new file mode 100644 index 0000000..998c567 --- /dev/null +++ b/rest-api-spec/test/termvector/10_basic.yaml @@ -0,0 +1,35 @@ +setup: + - do: + indices.create: + index: testidx + body: + mappings: + testtype: + "properties": + "text": + "type" : "string" + "term_vector" : "with_positions_offsets" + - do: + index: + index: testidx + type: testtype + id: testing_document + body: + "text" : "The quick brown fox is brown." + - do: + indices.refresh: {} + +--- +"Basic tests for termvector get": + + - do: + termvector: + index: testidx + type: testtype + id: testing_document + "term_statistics" : true + + + - match: {term_vectors.text.field_statistics.sum_doc_freq: 5} + - match: {term_vectors.text.terms.brown.doc_freq: 1} + - match: {term_vectors.text.terms.brown.tokens.0.start_offset: 10} diff --git a/rest-api-spec/test/update/10_doc.yaml b/rest-api-spec/test/update/10_doc.yaml new file mode 100644 index 0000000..b4581ed --- /dev/null +++ b/rest-api-spec/test/update/10_doc.yaml @@ -0,0 +1,40 @@ +--- +"Partial document": + + - do: + index: + index: test_1 + type: test + id: 1 + body: + foo: bar + count: 1 + nested: { one: 1, two: 2 } + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: + foo: baz + nested: + one: 3 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - match: { _version: 2 } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: baz } + - match: { _source.count: 1 } + - match: { _source.nested.one: 3 } + - match: { _source.nested.two: 2 } + diff --git a/rest-api-spec/test/update/15_script.yaml b/rest-api-spec/test/update/15_script.yaml new file mode 100644 index 0000000..c8cfc5f --- /dev/null +++ b/rest-api-spec/test/update/15_script.yaml @@ -0,0 +1,79 @@ +--- +"Script": + + - do: + index: + index: test_1 + type: test + id: 1 + body: + foo: bar + count: 1 + + - do: + update: + index: test_1 + type: test + id: 1 + script: "1" + body: + lang: mvel + script: "ctx._source.foo = bar" + params: { bar: 'xxx' } + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - match: { _version: 2 } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: xxx } + - match: { _source.count: 1 } + + - do: + update: + index: test_1 + type: test + id: 1 + lang: mvel + script: "ctx._source.foo = 'yyy'" + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: "1" } + - match: { _version: 3 } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: yyy } + - match: { _source.count: 1 } + + - do: + catch: /script_lang not supported \[doesnotexist\]/ + update: + index: test_1 + type: test + id: 1 + body: + script: "1" + lang: "doesnotexist" + params: { bar: 'xxx' } + + - do: + catch: /script_lang not supported \[doesnotexist\]/ + update: + index: test_1 + type: test + id: 1 + lang: doesnotexist + script: "1" + diff --git a/rest-api-spec/test/update/20_doc_upsert.yaml b/rest-api-spec/test/update/20_doc_upsert.yaml new file mode 100644 index 0000000..f34e030 --- /dev/null +++ b/rest-api-spec/test/update/20_doc_upsert.yaml @@ -0,0 +1,41 @@ +--- +"Doc upsert": + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar, count: 1 } + upsert: { foo: baz } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: baz } + - is_false: _source.count + + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar, count: 1 } + upsert: { foo: baz } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: bar } + - match: { _source.count: 1 } + + diff --git a/rest-api-spec/test/update/22_doc_as_upsert.yaml b/rest-api-spec/test/update/22_doc_as_upsert.yaml new file mode 100644 index 0000000..af25730 --- /dev/null +++ b/rest-api-spec/test/update/22_doc_as_upsert.yaml @@ -0,0 +1,41 @@ +--- +"Doc as upsert": + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: bar, count: 1 } + doc_as_upsert: 1 + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: bar } + - match: { _source.count: 1 } + + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { count: 2 } + doc_as_upsert: 1 + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: bar } + - match: { _source.count: 2 } + + diff --git a/rest-api-spec/test/update/25_script_upsert.yaml b/rest-api-spec/test/update/25_script_upsert.yaml new file mode 100644 index 0000000..64226b7 --- /dev/null +++ b/rest-api-spec/test/update/25_script_upsert.yaml @@ -0,0 +1,41 @@ +--- +"Script upsert": + + - do: + update: + index: test_1 + type: test + id: 1 + body: + script: "ctx._source.foo = bar" + params: { bar: 'xxx' } + upsert: { foo: baz } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: baz } + + + - do: + update: + index: test_1 + type: test + id: 1 + body: + script: "ctx._source.foo = bar" + params: { bar: 'xxx' } + upsert: { foo: baz } + + - do: + get: + index: test_1 + type: test + id: 1 + + - match: { _source.foo: xxx } + + diff --git a/rest-api-spec/test/update/30_internal_version.yaml b/rest-api-spec/test/update/30_internal_version.yaml new file mode 100644 index 0000000..c9f3706 --- /dev/null +++ b/rest-api-spec/test/update/30_internal_version.yaml @@ -0,0 +1,47 @@ +--- +"Internal version": + + - do: + catch: conflict + update: + index: test_1 + type: test + id: 1 + version: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { _version: 1} + + - do: + catch: conflict + update: + index: test_1 + type: test + id: 1 + version: 2 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + update: + index: test_1 + type: test + id: 1 + version: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { _version: 2} diff --git a/rest-api-spec/test/update/35_external_version.yaml b/rest-api-spec/test/update/35_external_version.yaml new file mode 100644 index 0000000..a3ca3a9 --- /dev/null +++ b/rest-api-spec/test/update/35_external_version.yaml @@ -0,0 +1,40 @@ +--- +"External version": + + - do: + update: + index: test_1 + type: test + id: 1 + version: 2 + version_type: external + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { _version: 2 } + + - do: + catch: conflict + update: + index: test_1 + type: test + id: 1 + version: 2 + version_type: external + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + update: + index: test_1 + type: test + id: 1 + version: 3 + version_type: external + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { _version: 3 } diff --git a/rest-api-spec/test/update/40_routing.yaml b/rest-api-spec/test/update/40_routing.yaml new file mode 100644 index 0000000..52cd938 --- /dev/null +++ b/rest-api-spec/test/update/40_routing.yaml @@ -0,0 +1,56 @@ +--- +"Routing": + + - do: + indices.create: + index: test_1 + body: + settings: + index: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + update: + index: test_1 + type: test + id: 1 + routing: 5 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 5 + fields: _routing + + - match: { fields._routing: "5"} + + - do: + catch: missing + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + + - do: + update: + index: test_1 + type: test + id: 1 + routing: 5 + fields: foo + body: + doc: { foo: baz } + + - match: { get.fields.foo: [baz] } + diff --git a/rest-api-spec/test/update/50_parent.yaml b/rest-api-spec/test/update/50_parent.yaml new file mode 100644 index 0000000..3d15ea9 --- /dev/null +++ b/rest-api-spec/test/update/50_parent.yaml @@ -0,0 +1,79 @@ +--- +setup: + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + +--- +"Parent": + + - do: + catch: /RoutingMissingException/ + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + update: + index: test_1 + type: test + id: 1 + parent: 5 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + fields: [_parent, _routing] + + - match: { fields._parent: "5"} + - match: { fields._routing: "5"} + + - do: + update: + index: test_1 + type: test + id: 1 + parent: 5 + fields: foo + body: + doc: { foo: baz } + + - match: { get.fields.foo: [baz] } + +--- +"Parent omitted": + + - do: + index: + index: test_1 + type: test + id: 1 + parent: 5 + body: { foo: bar } + + - do: + catch: request + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + diff --git a/rest-api-spec/test/update/55_parent_with_routing.yaml b/rest-api-spec/test/update/55_parent_with_routing.yaml new file mode 100644 index 0000000..cc82802 --- /dev/null +++ b/rest-api-spec/test/update/55_parent_with_routing.yaml @@ -0,0 +1,63 @@ +--- +"Parent with routing": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + settings: + number_of_replicas: 0 + + - do: + cluster.health: + wait_for_status: green + + - do: + update: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + routing: 4 + parent: 5 + fields: [_parent, _routing] + + - match: { fields._parent: "5"} + - match: { fields._routing: "4"} + + - do: + catch: missing + update: + index: test_1 + type: test + id: 1 + parent: 5 + body: + doc: { foo: baz } + + - do: + update: + index: test_1 + type: test + id: 1 + parent: 5 + routing: 4 + fields: foo + body: + doc: { foo: baz } + + - match: { get.fields.foo: [baz] } + diff --git a/rest-api-spec/test/update/60_refresh.yaml b/rest-api-spec/test/update/60_refresh.yaml new file mode 100644 index 0000000..6048292 --- /dev/null +++ b/rest-api-spec/test/update/60_refresh.yaml @@ -0,0 +1,50 @@ +--- +"Refresh": + + - do: + indices.create: + index: test_1 + body: + settings: + index.refresh_interval: -1 + number_of_replicas: 0 + - do: + cluster.health: + wait_for_status: yellow + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + search: + index: test_1 + type: test + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 0 } + + - do: + update: + index: test_1 + type: test + id: 2 + refresh: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + search: + index: test_1 + type: test + body: + query: { term: { _id: 2 }} + + - match: { hits.total: 1 } diff --git a/rest-api-spec/test/update/70_timestamp.yaml b/rest-api-spec/test/update/70_timestamp.yaml new file mode 100644 index 0000000..368f750 --- /dev/null +++ b/rest-api-spec/test/update/70_timestamp.yaml @@ -0,0 +1,77 @@ +--- +"Timestamp": + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _timestamp: + enabled: 1 + store: yes + - do: + cluster.health: + wait_for_status: yellow + +# blank timestamp + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - is_true: fields._timestamp + +# milliseconds since epoch + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + timestamp: 1372011280000 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - match: { fields._timestamp: 1372011280000 } + +# date format + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + timestamp: 2013-06-23T18:14:40 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _timestamp + + - match: { fields._timestamp: 1372011280000 } + diff --git a/rest-api-spec/test/update/75_ttl.yaml b/rest-api-spec/test/update/75_ttl.yaml new file mode 100644 index 0000000..2075c6b --- /dev/null +++ b/rest-api-spec/test/update/75_ttl.yaml @@ -0,0 +1,96 @@ +--- +"TTL": + + - skip: + features: gtelte + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _ttl: + enabled: 1 + store: yes + default: 10s + - do: + cluster.health: + wait_for_status: yellow + +# blank ttl + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 10000} + - gt: { fields._ttl: 0} + +# milliseconds + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + ttl: 100000 + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 100000} + - gt: { fields._ttl: 10000} + +# duration + + - do: + update: + index: test_1 + type: test + id: 1 + body: + doc: { foo: baz } + upsert: { foo: bar } + ttl: 20s + + - do: + get: + index: test_1 + type: test + id: 1 + fields: _ttl + + - lte: { fields._ttl: 20000} + - gt: { fields._ttl: 10000} + +# with timestamp + + - do: + catch: /AlreadyExpiredException/ + index: + index: test_1 + type: test + id: 1 + body: { foo: bar } + ttl: 20s + timestamp: 2013-06-23T18:14:40 + diff --git a/rest-api-spec/test/update/80_fields.yaml b/rest-api-spec/test/update/80_fields.yaml new file mode 100644 index 0000000..86d6afa --- /dev/null +++ b/rest-api-spec/test/update/80_fields.yaml @@ -0,0 +1,20 @@ +--- +"Fields": + + - do: + update: + index: test_1 + type: test + id: 1 + fields: foo,bar,_source + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { get._source.foo: bar } + - match: { get.fields.foo: [bar] } + - is_false: get.fields.bar + +# TODO: +# +# - Add _routing diff --git a/rest-api-spec/test/update/85_fields_meta.yaml b/rest-api-spec/test/update/85_fields_meta.yaml new file mode 100644 index 0000000..97cefa1 --- /dev/null +++ b/rest-api-spec/test/update/85_fields_meta.yaml @@ -0,0 +1,51 @@ +--- +"Metadata Fields": + + - skip: + version: "0 - 999" + reason: "Update doesn't return metadata fields, waiting for #3259" + + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + _timestamp: + enabled: 1 + store: yes + _ttl: + enabled: 1 + store: yes + default: 10s + + - do: + cluster.health: + wait_for_status: yellow + + - do: + update: + index: test_1 + type: test + id: 1 + parent: 5 + fields: [ _parent, _routing, _timestamp, _ttl ] + body: + doc: { foo: baz } + upsert: { foo: bar } + + - match: { get.fields._parent: "5" } + - match: { get.fields._routing: "5" } + - is_true: get.fields._timestamp + - is_true: get.fields._ttl + + - do: + get: + index: test_1 + type: test + id: 1 + parent: 5 + fields: [ _parent, _routing, _timestamp, _ttl ] + + diff --git a/rest-api-spec/test/update/90_missing.yaml b/rest-api-spec/test/update/90_missing.yaml new file mode 100644 index 0000000..d51c54c --- /dev/null +++ b/rest-api-spec/test/update/90_missing.yaml @@ -0,0 +1,42 @@ +--- +"Missing document (partial doc)": + + - do: + catch: missing + update: + index: test_1 + type: test + id: 1 + body: { doc: { foo: bar } } + + - do: + update: + index: test_1 + type: test + id: 1 + body: { doc: { foo: bar } } + ignore: 404 + +--- +"Missing document (script)": + + + - do: + catch: missing + update: + index: test_1 + type: test + id: 1 + body: + script: "ctx._source.foo = bar" + params: { bar: 'xxx' } + + - do: + update: + index: test_1 + type: test + id: 1 + ignore: 404 + body: + script: "ctx._source.foo = bar" + params: { bar: 'xxx' } diff --git a/rest-api-spec/test/update/TODO.txt b/rest-api-spec/test/update/TODO.txt new file mode 100644 index 0000000..6eefbfd --- /dev/null +++ b/rest-api-spec/test/update/TODO.txt @@ -0,0 +1,7 @@ +Tests missing for: + +# consistency +# percolate +# replication +# retry_on_conflict +# timeout
\ No newline at end of file diff --git a/rest-api-spec/utils/Gemfile b/rest-api-spec/utils/Gemfile new file mode 100644 index 0000000..313d822 --- /dev/null +++ b/rest-api-spec/utils/Gemfile @@ -0,0 +1,9 @@ +source 'https://rubygems.org' + +gem 'activesupport' +gem 'rest-client' +gem 'coderay' +gem 'multi_json' +gem 'thor' +gem 'json' +gem 'pry' diff --git a/rest-api-spec/utils/Thorfile b/rest-api-spec/utils/Thorfile new file mode 100644 index 0000000..d0d8190 --- /dev/null +++ b/rest-api-spec/utils/Thorfile @@ -0,0 +1,3 @@ +require File.expand_path('./thor/generate_api') +require File.expand_path('./thor/generate_source') +require File.expand_path('./thor/lister') diff --git a/rest-api-spec/utils/thor/generate_api.rb b/rest-api-spec/utils/thor/generate_api.rb new file mode 100644 index 0000000..8755bef --- /dev/null +++ b/rest-api-spec/utils/thor/generate_api.rb @@ -0,0 +1,189 @@ +require 'thor' + +require 'pathname' +require 'active_support/core_ext/hash/deep_merge' +require 'active_support/inflector/methods' +require 'rest_client' +require 'json' +require 'pry' + +module Elasticsearch + + module API + module Utils + # controller.registerHandler(RestRequest.Method.GET, "/_cluster/health", this); + PATTERN_REST = /.*controller.registerHandler\(.*(?<method>GET|POST|PUT|DELETE|HEAD|OPTIONS|PATCH)\s*,\s*"(?<url>.*)"\s*,\s*.+\);/ + # request.param("index"), request.paramAsBoolean("docs", indicesStatsRequest.docs()), etc + PATTERN_URL_PARAMS = /request.param.*\("(?<param>[a-z_]+)".*/ + # controller.registerHandler(GET, "/{index}/_refresh", this) + PATTERN_URL_PARTS = /\{(?<part>[a-zA-Z0-9\_\-]+)\}/ + # request.hasContent() + PATTERN_HAS_BODY = /request\.hasContent()/ + + # Parses the Elasticsearch source code and returns a Hash of REST API information/specs. + # + # Example: + # + # { + # "cluster.health" => [ + # { "method" => "GET", + # "path" => "/_cluster/health", + # "parts" => ["index"], + # "params" => ["index", "local", ... ], + # "body" => false + # } + # + def __parse_java_source(path) + path += '/' unless path =~ /\/$/ # Add trailing slash if missing + prefix = "src/main/java/org/elasticsearch/rest/action" + + java_rest_files = Dir["#{path}#{prefix}/**/*.java"] + + map = {} + + java_rest_files.sort.each do |file| + content = File.read(file) + parts = file.gsub(path+prefix, '').split('/') + name = parts[0, parts.size-1].reject { |p| p =~ /^\s*$/ }.join('.') + + # Remove the `admin` namespace + name.gsub! /admin\./, '' + + # Extract params + url_params = content.scan(PATTERN_URL_PARAMS).map { |n| n.first }.sort + + # Extract parts + url_parts = content.scan(PATTERN_URL_PARTS).map { |n| n.first }.sort + + # Extract if body allowed + has_body = !!content.match(PATTERN_HAS_BODY) + + # Extract HTTP method and path + content.scan(PATTERN_REST) do |method, path| + (map[name] ||= []) << { 'method' => method, + 'path' => path, + 'parts' => url_parts, + 'params' => url_params, + 'body' => has_body } + end + + end + + map + end + + extend self + end + + # Contains a generator which will parse the Elasticsearch *.java source files, + # extract information about REST API endpoints (URLs, HTTP methods, URL parameters, etc), + # and create a skeleton of the JSON API specification file for each endpoint. + # + # Usage: + # + # $ thor help api:generate:spec + # + # Example: + # + # time thor api:generate:spec \ + # --force \ + # --verbose \ + # --crawl \ + # --elasticsearch=/path/to/elasticsearch/source/code + # + # Features: + # + # * Extract the API name from the source filename (eg. `admin/cluster/health/RestClusterHealthAction.java` -> `cluster.health`) + # * Extract the URLs from the `registerHandler` statements + # * Extract the URL parts (eg. `{index}`) from the URLs + # * Extract the URL parameters (eg. `{timeout}`) from the `request.param("ABC")` statements + # * Detect whether HTTP body is allowed for the API from `request.hasContent()` statements + # * Search the <http://elasticsearch.org> website to get proper documentation URLs + # * Assemble the JSON format for the API spec + # + class JsonGenerator < Thor + namespace 'api:spec' + + include Thor::Actions + + __root = Pathname( File.expand_path('../../..', __FILE__) ) + + # Usage: thor help api:generate:spec + # + desc "generate", "Generate JSON API spec files from Elasticsearch source code" + method_option :force, type: :boolean, default: false, desc: 'Overwrite the output' + method_option :verbose, type: :boolean, default: false, desc: 'Output more information' + method_option :output, default: __root.join('tmp/out'), desc: 'Path to output directory' + method_option :elasticsearch, default: __root.join('tmp/elasticsearch'), desc: 'Path to directory with Elasticsearch source code' + method_option :crawl, type: :boolean, default: false, desc: 'Extract URLs from Elasticsearch website' + + def generate + self.class.source_root File.expand_path('../', __FILE__) + + @output = Pathname(options[:output]) + + rest_actions = Utils.__parse_java_source(options[:elasticsearch].to_s) + + if rest_actions.empty? + say_status 'ERROR', 'Cannot find Elasticsearch source in ' + options[:elasticsearch].to_s, :red + exit(1) + end + + rest_actions.each do |name, info| + doc_url = "" + parts = info.reduce([]) { |sum, n| sum |= n['parts']; sum }.reduce({}) { |sum, n| sum[n] = {}; sum } + params = info.reduce([]) { |sum, n| sum |= n['params']; sum }.reduce({}) { |sum, n| sum[n] = {}; sum } + + if options[:crawl] + begin + response = RestClient.get "http://search.elasticsearch.org/elastic-search-website/guide/_search?q=#{URI.escape(name.gsub(/\./, ' '))}" + hits = JSON.load(response)['hits']['hits'] + if hit = hits.first + if hit['_score'] > 0.2 + doc_title = hit['fields']['title'] + doc_url = "http://elasticsearch.org" + hit['fields']['url'] + end + end + rescue Exception => e + puts "[!] ERROR: #{e.inspect}" + end + end + + spec = { + name => { + 'documentation' => doc_url, + + 'methods' => info.map { |n| n['method'] }.uniq, + + 'url' => { + 'path' => info.first['path'], + 'paths' => info.map { |n| n['path'] }.uniq, + 'parts' => parts, + 'params' => params + }, + + 'body' => info.first['body'] ? {} : nil + } + } + + json = JSON.pretty_generate(spec, indent: ' ', array_nl: '', object_nl: "\n", space: ' ', space_before: ' ') + + # Fix JSON array formatting + json.gsub!(/\[\s+/, '[') + json.gsub!(/, {2,}"/, ', "') + + create_file @output.join( "#{name}.json" ), json + "\n" + + if options[:verbose] + lines = json.split("\n") + say_status 'JSON', + lines.first + "\n" + lines[1, lines.size].map { |l| ' '*14 + l }.join("\n") + end + end + end + + private + + end + end +end diff --git a/rest-api-spec/utils/thor/generate_source.rb b/rest-api-spec/utils/thor/generate_source.rb new file mode 100644 index 0000000..2002da1 --- /dev/null +++ b/rest-api-spec/utils/thor/generate_source.rb @@ -0,0 +1,117 @@ +# encoding: UTF-8 + +require 'thor' + +require 'pathname' +require 'active_support/core_ext/hash/deep_merge' +require 'active_support/inflector' +require 'multi_json' +require 'coderay' +require 'pry' + +module Elasticsearch + + module API + + # A command line application based on [Thor](https://github.com/wycats/thor), + # which will read the JSON API spec file(s), and generate + # the Ruby source code (one file per API endpoint) with correct + # module namespace, method names, and RDoc documentation, + # as well as test files for each endpoint. + # + # Currently it only generates Ruby source, but can easily be + # extended and adapted to generate source code for other + # programming languages. + # + class SourceGenerator < Thor + namespace 'api:code' + + include Thor::Actions + + __root = Pathname( File.expand_path('../../..', __FILE__) ) + + desc "generate <PATH TO JSON SPEC FILES>", "Generate source code and tests from the REST API JSON specification" + method_option :language, default: 'ruby', desc: 'Programming language' + method_option :force, type: :boolean, default: false, desc: 'Overwrite the output' + method_option :verbose, type: :boolean, default: false, desc: 'Output more information' + method_option :input, default: File.expand_path('../../../api-spec', __FILE__), desc: 'Path to directory with JSON API specs' + method_option :output, default: File.expand_path('../../../tmp/out', __FILE__), desc: 'Path to output directory' + + def generate(*files) + self.class.source_root File.expand_path('../', __FILE__) + + @input = Pathname(options[:input]) + @output = Pathname(options[:output]) + + # -- Test helper + copy_file "templates/ruby/test_helper.rb", @output.join('test').join('test_helper.rb') if options[:language] == 'ruby' + + files.each do |file| + @path = Pathname(file) + @json = MultiJson.load( File.read(@path) ) + @spec = @json.values.first + say_status 'json', @path, :yellow + # say_status 'JSON', @spec.inspect, options[:verbose] + + @full_namespace = @json.keys.first.split('.') + @namespace_depth = @full_namespace.size > 0 ? @full_namespace.size-1 : 0 + @module_namespace = @full_namespace[0, @namespace_depth] + @method_name = @full_namespace.last + + # -- Ruby files + + @path_to_file = @output.join('api').join( @module_namespace.join('/') ).join("#{@method_name}.rb") + + empty_directory @output.join('api').join( @module_namespace.join('/') ) + + template "templates/#{options[:language]}/method.erb", @path_to_file + + if options[:verbose] + colorized_output = CodeRay.scan_file(@path_to_file, :ruby).terminal + lines = colorized_output.split("\n") + say_status options[:language].downcase, + lines.first + "\n" + lines[1, lines.size].map { |l| ' '*14 + l }.join("\n"), + :yellow + end + + # --- Test files + + @test_directory = @output.join('test/api').join( @module_namespace.join('/') ) + @test_file = @test_directory.join("#{@method_name}_test.rb") + + empty_directory @test_directory + template "templates/#{options[:language]}/test.erb", @test_file + + if options[:verbose] + colorized_output = colorized_output = CodeRay.scan_file(@test_file, :ruby).terminal + lines = colorized_output.split("\n") + say_status options[:language].downcase, + lines.first + "\n" + lines[1, lines.size].map { |l| ' '*14 + l }.join("\n"), + :yellow + say '▬'*terminal_width + end + end + + # -- Tree output + + if options[:verbose] && `which tree > /dev/null 2>&1` + lines = `tree #{@output}`.split("\n") + say_status 'tree', + lines.first + "\n" + lines[1, lines.size].map { |l| ' '*14 + l }.join("\n") + end + end + + private + + # Create the hierarchy of directories based on API namespaces + # + def __create_directories(key, value) + unless value['documentation'] + empty_directory @output.join(key) + create_directory_hierarchy *value.to_a.first + end + end + + end + end +end diff --git a/rest-api-spec/utils/thor/lister.rb b/rest-api-spec/utils/thor/lister.rb new file mode 100644 index 0000000..2402494 --- /dev/null +++ b/rest-api-spec/utils/thor/lister.rb @@ -0,0 +1,41 @@ +# encoding: UTF-8 + +require 'thor' + +require 'pathname' + +module Elasticsearch + + module API + + class Lister < Thor + namespace 'api' + + desc "list <PATH DIRECTORY WITH JSON SPEC FILES>", "List all the REST API endpoints from the JSON specification" + method_option :verbose, type: :boolean, default: false, desc: 'Output more information' + method_option :format, default: 'text', desc: 'Output format (text, json)' + def list(directory) + input = Pathname(directory).join('*.json') + apis = Dir[input.to_s].map do |f| + File.basename(f, '.json') + end.sort + + if options[:verbose] + say_status 'Count', apis.size + say '▬'*terminal_width + end + + case options[:format] + when 'text' + apis.each { |a| puts "* #{a}" } + when 'json' + puts apis.inspect + else + puts "[!] ERROR: Unknown output format '#{options[:format]}'" + exit(1) + end + end + end + + end +end diff --git a/rest-api-spec/utils/thor/templates/ruby/method.erb b/rest-api-spec/utils/thor/templates/ruby/method.erb new file mode 100644 index 0000000..7f13d2f --- /dev/null +++ b/rest-api-spec/utils/thor/templates/ruby/method.erb @@ -0,0 +1,64 @@ +module Elasticsearch + module API + <%- @module_namespace.each_with_index do |name, i| -%> + <%= ' '*i %>module <%= name.capitalize %> + <%- end -%> + <%= ' '*@namespace_depth %>module Actions + + <%= ' '*@namespace_depth %># <%= @spec['description'] || 'TODO: Description' %> + <%= ' '*@namespace_depth %># +<%# URL parts -%> + <%- @spec['url']['parts'].each do |name,info| -%> + <%- info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings' -%> + <%= ' '*@namespace_depth + "# @option arguments [#{info['type'] ? info['type'].capitalize : 'String'}] :#{name} #{info['description']}" + ( info['required'] ? ' (*Required*)' : '' ) -%><%= " (options: #{info['options'].join(', ')})" if info['options'] -%> + <%= "\n" -%> + <%- end -%> +<%# Body -%> +<%= ' '*(@namespace_depth+3) + '# @option arguments [Hash] :body ' + (@spec['body']['description'] || 'TODO: Description') + (@spec['body']['required'] ? ' (*Required*)' : '') + "\n" if @spec['body'] -%> +<%# URL parameters -%> + <%- @spec['url']['params'].each do |name,info| -%> + <%- info['type'] = 'String' if info['type'] == 'enum' # Rename 'enums' to 'strings' -%> + <%= ' '*@namespace_depth + "# @option arguments [#{info['type'] ? info['type'].capitalize : 'String'}] :#{name} #{info['description']}" -%><%= " (options: #{info['options'].join(', ')})" if info['options'] -%> + <%= "\n" -%> + <%- end -%> + <%= ' '*@namespace_depth -%># +<%# Documentation link -%> + <%= ' '*@namespace_depth %># @see <%= @spec['documentation'] %> + <%= ' '*@namespace_depth %># +<%# Method definition -%> + <%= ' '*@namespace_depth -%>def <%= @method_name %>(arguments={}) +<%# Required arguments -%> + <%- @spec['url']['parts'].select { |name, info| info['required'] }.each do |name, info| -%> + <%= ' '*(@namespace_depth+1) + "raise ArgumentError, \"Required argument '#{name}' missing\" unless arguments[:#{name}]" + "\n" -%> + <%- end -%> +<%- if @spec['body'] && @spec['body']['required'] -%> + <%= ' '*(@namespace_depth+1) + "raise ArgumentError, \"Required argument 'body' missing\" unless arguments[:body]" + "\n" -%> +<%- end -%> +<%# Method, path, params, body -%> + <%= ' '*@namespace_depth %> method = '<%= @spec['methods'].first %>' + <%- unless @spec['url']['parts'].empty? -%> + <%= ' '*@namespace_depth %> path = "<%= @spec['url']['path'].split('/').compact.reject {|p| p =~ /^\s*$/}.map do |p| + p =~ /\{/ ? "\#\{arguments[:#{p.tr('{}', '')}]\}" : p + end.join('/') %>" + <%- else -%> + <%= ' '*@namespace_depth %> path = "<%= @spec['url']['path'] %>" + <%- end -%> + <%- unless @spec['url']['params'].keys.empty? -%> + <%= ' '*@namespace_depth %> params = arguments.select do |k,v| + <%= ' '*@namespace_depth %> [ :<%= @spec['url']['params'].keys.join(",\n#{' '*(@namespace_depth+6)}:") %> ].include?(k) + <%= ' '*@namespace_depth %> end + <%= ' '*@namespace_depth %> # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour + <%= ' '*@namespace_depth %> params = Hash[params] unless params.is_a?(Hash) + <%- else -%> + <%= ' '*@namespace_depth %> params = {} + <%- end -%> + <%= ' '*@namespace_depth %> body = <%= @spec['body'].nil? ? 'nil' : 'arguments[:body]' %> +<%# Perform request %> + <%= ' '*@namespace_depth %> perform_request(method, path, params, body).body + <%= ' '*@namespace_depth %>end + <%- @namespace_depth.downto(1) do |i| -%> + <%= ' '*(i-1) %>end + <%- end if @namespace_depth > 0 -%> + end + end +end diff --git a/rest-api-spec/utils/thor/templates/ruby/test.erb b/rest-api-spec/utils/thor/templates/ruby/test.erb new file mode 100644 index 0000000..0825d81 --- /dev/null +++ b/rest-api-spec/utils/thor/templates/ruby/test.erb @@ -0,0 +1,26 @@ +require 'test_helper' + +module Elasticsearch + module Test + class <%= @module_namespace.empty? ? @method_name.camelize : @module_namespace.map {|n| n.capitalize}.join + @method_name.camelize %>Test < ::Test::Unit::TestCase + + context "<%= @module_namespace.empty? ? '' : @module_namespace.map {|n| n.capitalize}.join + ': ' %><%= @method_name.humanize %>" do + subject { FakeClient.new(nil) } + + should "perform correct request" do + subject.expects(:perform_request).with do |method, url, params, body| + assert_equal 'FAKE', method + assert_equal 'test', url + assert_equal Hash.new, params + <%= @spec['body'].nil? ? 'assert_nil body' : 'assert_equal Hash.new, body' %> + true + end.returns(FakeResponse.new) + + subject.<%= @full_namespace.join('.') %> + end + + end + + end + end +end diff --git a/rest-api-spec/utils/thor/templates/ruby/test_helper.rb b/rest-api-spec/utils/thor/templates/ruby/test_helper.rb new file mode 100644 index 0000000..6b822a1 --- /dev/null +++ b/rest-api-spec/utils/thor/templates/ruby/test_helper.rb @@ -0,0 +1,54 @@ +RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9' + +require 'rubygems' if RUBY_1_8 + +require 'simplecov' and SimpleCov.start { add_filter "/test|test_/" } if ENV["COVERAGE"] + +require 'test/unit' +require 'shoulda-context' +require 'mocha/setup' +require 'turn' unless ENV["TM_FILEPATH"] || ENV["NOTURN"] || RUBY_1_8 + +require 'require-prof' if ENV["REQUIRE_PROF"] +Dir[ File.expand_path('../../lib/elasticsearch/api/**/*.rb', __FILE__) ].each do |f| + puts 'Loading: ' + f.to_s if ENV['DEBUG'] + require f +end +RequireProf.print_timing_infos if ENV["REQUIRE_PROF"] + +module Elasticsearch + module Test + def __full_namespace(o) + o.constants.inject([o]) do |sum, c| + m = o.const_get(c.to_s.to_sym) + sum << __full_namespace(m).flatten if m.is_a?(Module) + sum + end.flatten + end; module_function :__full_namespace + + class FakeClient + # Include all "Actions" modules into the fake client + Elasticsearch::Test.__full_namespace(Elasticsearch::API).select { |m| m.to_s =~ /Actions$/ }.each do |m| + puts "Including: #{m}" if ENV['DEBUG'] + include m + end + + def perform_request(method, path, params, body) + puts "PERFORMING REQUEST:", "--> #{method.to_s.upcase} #{path} #{params} #{body}" + FakeResponse.new(200, 'FAKE', {}) + end + end + + FakeResponse = Struct.new(:status, :body, :headers) do + def status + values[0] || 200 + end + def body + values[1] || '{}' + end + def headers + values[2] || {} + end + end + end +end |