Merge pull request #161 from opensearch-project/document-rest-apis
Tweaked document REST APIs
This commit is contained in:
commit
62611a7605
|
@ -28,7 +28,7 @@ POST sample-index1/_delete_by_query
|
|||
## Path and HTTP methods
|
||||
|
||||
```
|
||||
POST <target>/_delete_by_query
|
||||
POST <index>/_delete_by_query
|
||||
```
|
||||
|
||||
## URL parameters
|
||||
|
@ -37,7 +37,8 @@ All URL parameters are optional.
|
|||
|
||||
Parameter | Type | Description
|
||||
:--- | :--- | :--- | :---
|
||||
<index> | String | Name of the data streams, indices, or aliases to delete from. Supports wildcards. If left blank, OpenSearch searches all indices.
|
||||
<index> | String | Name or list of the data streams, indices, or aliases to delete from. Supports wildcards. If left blank, OpenSearch searches all indices.
|
||||
allow_no_indices - Whether to ignore wildcards that don’t match any indices. Default is `true`.
|
||||
allow_no_indices | Boolean | False indicates to OpenSearch the request should return an error if any wildcard expression or index alias targets only missing or closed indices. Default is true.
|
||||
analyzer | String | The analyzer to use in the query string.
|
||||
analyze_wildcard | Boolean | Specifies whether to analyze wildcard and prefix queries. Default is false.
|
||||
|
@ -47,19 +48,18 @@ df | String | The default field in case a field prefix is not provided in the qu
|
|||
expand_wildcards | String | Specifies the type of index that wildcard expressions can match. Supports comma-separated values. Valid values are `all` (match any index), `open` (match open, non-hidden indices), `closed` (match closed, non-hidden indices), `hidden` (match hidden indices), and `none` (deny wildcard expressions). Default is `open`.
|
||||
from | Integer | The starting index to search from. Default is 0.
|
||||
ignore_unavailable | Boolean | Specifies whether to include missing or closed indices in the response. Default is false.
|
||||
lenient | Boolean | Specifies whether OpenSearch should ignore format-based query failures (for example, querying a text field for an integer). Default is false.
|
||||
max_docs | Integer | Maximum amount of documents the operation should process. Default is all documents.
|
||||
preference | String | Specifies the shard or node OpenSearch should perform the operation on.
|
||||
q | String | Query in the Lucene query string syntax.
|
||||
request_cache | Boolean | Specifies whether OpenSearch should use the request cache for the request. Default is whether it's enabled in the index's settings.
|
||||
refresh | Boolean | Specifies whether OpenSearch should refresh all of the shards involved in the delete request once the operation finishes. Default is false.
|
||||
lenient | Boolean | Specifies whether OpenSearch should accept requests if queries have format errors (for example, querying a text field for an integer). Default is false.
|
||||
max_docs | Integer | How many documents the delete by query operation should process at most. Default is all documents.
|
||||
preference | String | Specifies which shard or node OpenSearch should perform the delete by query operation on.
|
||||
q | String | Lucene query string's query.
|
||||
request_cache | Boolean | Specifies whether OpenSearch should use the request cache. Default is whether it’s enabled in the index’s settings.
|
||||
refresh | Boolean | If true, OpenSearch refreshes shards to make the delete by query operation available to search results. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is `false`.
|
||||
requests_per_second | Integer | Specifies the request's throttling in sub-requests per second. Default is -1, which means no throttling.
|
||||
routing | String | Value used to route the operation to a specific shard.
|
||||
scroll | Time | Amount of time the search context should be open.
|
||||
scroll_size | Integer | Size of the scroll request of the operation. Default is 1000.
|
||||
scroll_size | Integer | Size of the operation's scroll requests. Default is 1000.
|
||||
search_type | String | Whether OpenSearch should use global term and document frequencies calculating revelance scores. Valid choices are `query_then_fetch` and `dfs_query_then_fetch`. `query_then_fetch` scores documents using local term and document frequencies for the shard. It’s usually faster but less accurate. `dfs_query_then_fetch` scores documents using global term and document frequencies across all shards. It’s usually slower but more accurate. Default is `query_then_fetch`.
|
||||
search_timeout | Time | Amount of time until timeout for the search request. Default is no timeout.
|
||||
slices | Integer | Number of sub-tasks OpenSearch should divide this task into. Default is 1, which means OpenSearch should not divide this task.
|
||||
search_timeout | Time | How long to wait until OpenSearch deems the request timed out. Default is no timeout.
|
||||
sort | String | A comma-separated list of <field> : <direction> pairs to sort by.
|
||||
_source | String | Specifies whether to include the `_source` field in the response.
|
||||
_source_excludes | String | A comma-separated list of source fields to exclude from the response.
|
||||
|
|
|
@ -21,20 +21,20 @@ DELETE /sample-index1/_doc/1
|
|||
## Path and HTTP methods
|
||||
|
||||
```
|
||||
DELETE /<index-name>/_doc/<_id>
|
||||
DELETE /<index>/_doc/<_id>
|
||||
```
|
||||
|
||||
## URL parameters
|
||||
|
||||
Parameter | Type | Description | Required
|
||||
:--- | :--- | :--- | :---
|
||||
<index-name> | String | The index to delete from. | Yes
|
||||
<index> | String | The index to delete from. | Yes
|
||||
<_id> | String | The ID of the document to delete. | Yes
|
||||
if_seq_no | Integer | Only perform the delete operation if the document's version number matches the specified number. | No
|
||||
if_primary_term | Integer | Only perform the delete operation if the document has the specified primary term. | No
|
||||
refresh | Enum | If true, OpenSearch refreshes shards to make the operation visible to searching. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is false. | No
|
||||
refresh | Enum | If true, OpenSearch refreshes shards to make the delete operation available to search results. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is `false`. | No
|
||||
routing | String | Value used to route the operation to a specific shard. | No
|
||||
timeout | Time | How long to wait for a response from the cluster. | No
|
||||
timeout | Time | How long to wait for a response from the cluster. Default is `1m`. | No
|
||||
version | Integer | The version of the document to delete, which must match the last updated version of the document. | No
|
||||
version_type | Enum | Retrieves a specifically typed document. Available options are `external` (retrieve the document if the specified version number is greater than the document's current version) and `external_gte` (retrieve the document if the specified version number is greater than or equal to the document's current version). For example, to delete version 3 of a document, use `/_doc/1?version=3&version_type=external`. | No
|
||||
wait_for_active_shards | String | The number of active shards that must be available before OpenSearch processes the delete request. Default is 1 (only the primary shard). Set to `all` or a positive integer. Values greater than 1 require replicas. For example, if you specify a value of 3, the index must have two replicas distributed across two additional nodes for the operation to succeed. | No
|
||||
|
|
|
@ -37,9 +37,9 @@ Parameter | Type | Description
|
|||
:--- | :--- | :---
|
||||
preference | String | Specifies a preference of which shard to retrieve results from. Available options are `_local`, which tells the operation to retrieve results from a locally allocated shard replica, and a custom string value assigned to a specific shard replica. By default, OpenSearch executes get document operations on random shards.
|
||||
realtime | Boolean | Specifies whether the operation should run in realtime. If false, the operation waits for the index to refresh to analyze the source to retrieve data, which makes the operation near-realtime. Default is true.
|
||||
refresh | Boolean | If true, OpenSearch refreshes shards to make the operation visible to searching. Default is false.
|
||||
refresh | Boolean | If true, OpenSearch refreshes shards to make the get operation available to search results. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is `false`.
|
||||
routing | String | A value used to route the operation to a specific shard.
|
||||
stored_fields | Boolean | If true, the operation retrieves document fields stored in the index rather than the document's `_source`. Default is false.
|
||||
stored_fields | Boolean | Whether the get operation should retrieve fields stored in the index. Default is false.
|
||||
_source | String | Whether to include the `_source` field in the response body. Default is true.
|
||||
_source_excludes | String | A comma-separated list of source fields to exclude in the query response.
|
||||
_source_includes | String | A comma-separated list of source fields to include in the query response.
|
||||
|
|
|
@ -39,11 +39,11 @@ Parameter | Type | Description | Required
|
|||
:--- | :--- | :--- | :---
|
||||
<index> | String | Name of the index. | Yes
|
||||
<_id> | String | A unique identifier to attach to the document. To automatically generate an ID, use `POST <target>/doc` in your request instead of PUT. | No
|
||||
if_seq_no | Integer | Only perform the operation if the document has the specified sequence number. | No
|
||||
if_primary_term | Integer | Only perform the operation if the document has the specified primary term. | No
|
||||
if_seq_no | Integer | Only perform the index operation if the document has the specified sequence number. | No
|
||||
if_primary_term | Integer | Only perform the index operation if the document has the specified primary term.| No
|
||||
op_type | Enum | Specifies the type of operation to complete with the document. Valid values are `create` (create the index if it doesn't exist) and `index`. If a document ID is included in the request, then the default is `index`. Otherwise, the default is `create`. | No
|
||||
pipeline | String | ID used to route the indexing operation to a certain pipeline. | No
|
||||
routing | String | Value used to assign operations to specific shards. | No
|
||||
pipeline | String | Route the index operation to a certain pipeline. | No
|
||||
routing | String | value used to assign the index operation to a specific shard. | No
|
||||
timeout | Time | How long to wait for a response from the cluster. Default is `1m`. | No
|
||||
version | Integer | The document's version number. | No
|
||||
version_type | Enum | Assigns a specific type to the document. Valid options are `external` (retrieve the document if the specified version number is greater than the document's current version) and `external_gte` (retrieve the document if the specified version number is greater than or equal to the document's current version). For example, to index version 3 of a document, use `/_doc/1?version=3&version_type=external`. | No
|
||||
|
@ -86,7 +86,7 @@ _index | The name of the index.
|
|||
_type | The document's type. OpenSearch supports only one type, which is `_doc`.
|
||||
_id | The document's ID.
|
||||
_version | The document's version.
|
||||
_result | The result of the index operation.
|
||||
result | The result of the index operation.
|
||||
_shards | Detailed information about the cluster's shards.
|
||||
total | The total number of shards.
|
||||
successful | The number of shards OpenSearch succssfully added the document to.
|
||||
|
|
|
@ -16,7 +16,6 @@ The multi-get operation allows you to execute multiple GET operations in one req
|
|||
|
||||
```json
|
||||
GET _mget
|
||||
|
||||
{
|
||||
"docs": [
|
||||
{
|
||||
|
@ -69,11 +68,11 @@ All multi-get URL parameters are optional.
|
|||
Parameter | Type | Description
|
||||
:--- | :--- | :--- | :---
|
||||
<index> | String | Name of the index to retrieve documents from.
|
||||
preference | String | The node or shard that OpenSearch should perform the operation on. Default is random.
|
||||
preference | String | Specifies the nodes or shards OpenSearch should execute the multi-get operation on. Default is random.
|
||||
realtime | Boolean | Specifies whether the operation should run in realtime. If false, the operation waits for the index to refresh to analyze the source to retrieve data, which makes the operation near-realtime. Default is `true`.
|
||||
refresh | Boolean | If true, OpenSearch refreshes shards to make the operation visible to searching. Default is `false`.
|
||||
routing | String | A value used to route the operation to a specific shard.
|
||||
stored_fields | Boolean | If true, the operation retrieves document fields stored in the index rather than the document's `_source`. Default is `false`.
|
||||
refresh | Boolean | If true, OpenSearch refreshes shards to make the multi-get operation available to search results. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is `false`.
|
||||
routing | String | Value used to route the multi-get operation to a specific shard.
|
||||
stored_fields | Boolean | Specifies whether OpenSearch should retrieve documents fields from the index instead of the document's `_source`. Default is `false`.
|
||||
_source | String | Whether to include the `_source` field in the query response. Default is `true`.
|
||||
_source_excludes | String | A comma-separated list of source fields to exclude in the query response.
|
||||
_source_includes | String | A comma-separated list of source fields to include in the query response.
|
||||
|
|
|
@ -44,31 +44,31 @@ All URL parameters are optional.
|
|||
|
||||
Parameter | Type | Description
|
||||
:--- | :--- | :--- | :---
|
||||
<target-index> | String | Comma-separated list of indices to update. To update all indices, use * or omit this parameter.
|
||||
allow_no_indices | String | If false, the request returns an error if wildcard expressions match closed or missing indices. Default is true.
|
||||
<index> | String | Comma-separated list of indices to update. To update all indices, use * or omit this parameter.
|
||||
allow_no_indices | String | Whether to ignore wildcards that don’t match any indices. Default is true.
|
||||
analyzer | String | Analyzer to use in the query string.
|
||||
analyze_wildcard | Boolean | Whether the operation should include wildcard and prefix queries in the analysis. Default is false.
|
||||
conflicts | String | Specifies whether the operation should continue if the request runs into version conflicts. Valid options are `abort` and `proceed`. Default is `abort`.
|
||||
default_operator | String | The default operator the string query should use. Valid options are `AND` and `OR`. Default is `OR`.
|
||||
df | String | The default field when the query string does not have a field prefix.
|
||||
analyze_wildcard | Boolean | Whether the update operation should include wildcard and prefix queries in the analysis. Default is false.
|
||||
conflicts | String | Indicates to OpenSearch what should happen if the update by query operation runs into a version conflict. Valid options are `abort` and `proceed`. Default is `abort`.
|
||||
default_operator | String | Indicates whether the default operator for a string query should be `AND` or `OR`. Default is `OR`.
|
||||
df | String | The default field if a field prefix is not provided in the query string.
|
||||
expand_wildcards | String | Specifies the type of index that wildcard expressions can match. Supports comma-separated values. Valid values are `all` (match any index), `open` (match open, non-hidden indices), `closed` (match closed, non-hidden indices), `hidden` (match hidden indices), and `none` (deny wildcard expressions). Default is `open`.
|
||||
from | Integer | The starting index to search from. Default is 0.
|
||||
ignore_unavailable | Boolean | Whether to exclude missing or closed indices in the response. Default is false.
|
||||
lenient | Boolean | Whether OpenSearch should ignore format-based query failures (for example, querying an integer field for a string). Default is false.
|
||||
max_docs | Integer | Maximum number of documents the request should process. Default is all documents.
|
||||
lenient | Boolean | Specifies whether OpenSearch should accept requests if queries have format errors (for example, querying a text field for an integer). Default is false.
|
||||
max_docs | Integer | How many documents the update by query operation should process at most. Default is all documents.
|
||||
pipeline | String | ID of the pipeline to use to process documents.
|
||||
preference | String | The node or shard OpenSearch should perform the operation on.
|
||||
q | String | Query in the Lucene query string syntax.
|
||||
request_cache | Boolean | Whether OpenSearch should use the request cache for the operation. Default is whether it's enabled in the index's settings.
|
||||
refresh | Boolean | Specifies whether OpenSearch should refresh shards involved in the operation to make the operation visible to searching.
|
||||
preference | String | Specifies which shard or node OpenSearch should perform the update by query operation on.
|
||||
q | String | Lucene query string's query.
|
||||
request_cache | Boolean | Specifies whether OpenSearch should use the request cache. Default is whether it’s enabled in the index’s settings.
|
||||
refresh | Boolean | If true, OpenSearch refreshes shards to make the update by query operation available to search results. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is `false`.
|
||||
requests_per_second | Integer | Specifies the request's throttling in sub-requests per second. Default is -1, which means no throttling.
|
||||
routing | String | Value used to route the operation to a specific shard.
|
||||
routing | String | Value used to route the update by query operation to a specific shard.
|
||||
scroll | Time | How long to keep the search context open.
|
||||
scroll_size | Integer | Size of the operation's scroll request. Default is 1000.
|
||||
search_type | String | Whether OpenSearch should use global term and document frequencies calculating revelance scores. Valid choices are `query_then_fetch` and `dfs_query_then_fetch`. `query_then_fetch` scores documents using local term and document frequencies for the shard. It’s usually faster but less accurate. `dfs_query_then_fetch` scores documents using global term and document frequencies across all shards. It’s usually slower but more accurate. Default is `query_then_fetch`.
|
||||
search_timeout | Time | Amount of time until timeout for the search request. Default is no timeout.
|
||||
search_timeout | Time | How long to wait until OpenSearch deems the request timed out. Default is no timeout.
|
||||
slices | Integer | Number of sub-tasks OpenSearch should divide this task into. Default is 1, which means OpenSearch should not divide this task.
|
||||
sort | String | A comma-separated list of <field> : <direction> pairs to sort by.
|
||||
sort | List | A comma-separated list of <field> : <direction> pairs to sort by.
|
||||
_source | String | Whether to include the `_source` field in the response.
|
||||
_source_excludes | String | A comma-separated list of source fields to exclude from the response.
|
||||
_source_includes | String | A comma-separated list of source fields to include in the response.
|
||||
|
|
|
@ -30,11 +30,7 @@ POST /sample-index1/_update/1
|
|||
POST /test-index1/_update/1
|
||||
{
|
||||
"script" : {
|
||||
"source": "ctx._source.oldValue += params.newValue",
|
||||
"lang": "painless",
|
||||
"params" : {
|
||||
"newValue" : 10
|
||||
}
|
||||
"source": "ctx._source.secret_identity = \"Batman\""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -42,22 +38,22 @@ POST /test-index1/_update/1
|
|||
## Path and HTTP methods
|
||||
|
||||
```
|
||||
POST /<index-name>/_update/<_id>
|
||||
POST /<index>/_update/<_id>
|
||||
```
|
||||
|
||||
## URL parameters
|
||||
|
||||
Parameter | Type | Description | Required
|
||||
:--- | :--- | :--- | :---
|
||||
<index-name> | String | Name of the index. | Yes
|
||||
<index> | String | Name of the index. | Yes
|
||||
<_id> | String | The ID of the document to update. | Yes
|
||||
if_seq_no | Integer | Only perform the delete operation if the document's version number matches the specified number. | No
|
||||
if_primary_term | Integer | Only perform the delete operation if the document has the specified primary term. | No
|
||||
if_primary_term | Integer | Perform the update operation if the document has the specified primary term. | No
|
||||
lang | String | Language of the script. Default is `painless`. | No
|
||||
require_alias | Boolean | Specifies whether the destination must be an index alias. Default is false. | No
|
||||
refresh | Enum | If true, OpenSearch refreshes shards to make the operation visible to searching. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is false. | No
|
||||
refresh | Enum | If true, OpenSearch refreshes shards to make the operation visible to searching. Valid options are `true`, `false`, and `wait_for`, which tells OpenSearch to wait for a refresh before executing the operation. Default is `false`. | No
|
||||
retry_on_conflict | Integer | The amount of times OpenSearch should retry the operation if there's a document conflict. Default is 0. | No
|
||||
routing | String | Value used to route the operation to a specific shard. | No
|
||||
routing | String | Value to route the update operation to a specific shard. | No
|
||||
_source | List | Whether to include the `_source` field in the response body. Default is true. | No
|
||||
_source_excludes | List | A comma-separated list of source fields to exclude in the query response. | No
|
||||
_source_includes | List | A comma-separated list of source fields to include in the query response. | No
|
||||
|
|
Loading…
Reference in New Issue