Adds copy buttons to API and field type sections (#2518)

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>
This commit is contained in:
kolchfa-aws 2023-01-30 17:09:38 -05:00 committed by GitHub
parent b593ca8eed
commit 7992ec0196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
104 changed files with 338 additions and 16 deletions

View File

@ -29,7 +29,6 @@ POST _aliases
"alias": "old-index-alias"
}
}
]
}
```

View File

@ -85,6 +85,7 @@ GET /_analyze
"text" : ["first array element", "second array element"]
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -150,6 +151,7 @@ GET /_analyze
"text" : "OpenSearch text analysis"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -196,6 +198,7 @@ GET /books2/_analyze
"text" : "Le garçon m'a SUIVI."
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -248,6 +251,7 @@ GET /_analyze
"text" : "OpenSearch filter"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -277,6 +281,7 @@ GET /_analyze
"text" : "<b>Leave</b> right now!"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -308,6 +313,7 @@ GET /_analyze
"text" : "how to train your dog in five steps"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -372,6 +378,7 @@ GET /books/_analyze
"text" : "OpenSearch analyze test"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -414,6 +421,7 @@ GET /books/_analyze
"text" : "OpenSearch analyze test"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -446,6 +454,7 @@ GET /books2/_analyze
"text" : "OpenSearch analyze test"
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -492,6 +501,7 @@ GET /books2/_analyze
"text" : "C'est le garçon qui m'a suivi."
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -522,6 +532,7 @@ GET /_analyze
"text" : "That is the boy who followed me."
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -555,6 +566,7 @@ GET /_analyze
"attributes" : ["keyword"]
}
````
{% include copy-curl.html %}
The previous request returns the following fields:
@ -635,6 +647,8 @@ PUT /books2
}
}
````
{% include copy-curl.html %}
The preceding request is an index API rather than an analyze API. See [DYNAMIC INDEX SETTINGS]({{site.url}}{{site.baseurl}}/api-reference/index-apis/create-index/#dynamic-index-settings) for additional details.
{: .note}

View File

@ -18,18 +18,21 @@ The CAT aliases operation lists the mapping of aliases to indices, plus routing
```json
GET _cat/aliases?v
```
{% include copy-curl.html %}
To limit the information to a specific alias, add the alias name after your query:
```json
GET _cat/aliases/<alias>?v
```
{% include copy-curl.html %}
If you want to get information for more than one alias, separate the alias names with commas:
```json
GET _cat/aliases/alias1,alias2,alias3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The CAT allocation operation lists the allocation of disk space for indices and
```json
GET _cat/allocation?v
```
{% include copy-curl.html %}
To limit the information to a specific node, add the node name after your query:
```json
GET _cat/allocation/<node_name>
```
{% include copy-curl.html %}
If you want to get information for more than one node, separate the node names with commas:
```json
GET _cat/allocation/node_name_1,node_name_2,node_name_3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT cluster manager operation lists information that helps identify the elec
```
GET _cat/cluster_manager?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The CAT count operation lists the number of documents in your cluster.
```json
GET _cat/count?v
```
{% include copy-curl.html %}
To see the number of documents in a specific index or alias, add the index or alias name after your query:
```json
GET _cat/count/<index_or_alias>?v
```
{% include copy-curl.html %}
If you want to get information for more than one index or alias, separate the index or alias names with commas:
```json
GET _cat/count/index_or_alias_1,index_or_alias_2,index_or_alias_3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The CAT fielddata operation lists the memory size used by each field per node.
```json
GET _cat/fielddata?v
```
{% include copy-curl.html %}
To limit the information to a specific field, add the field name after your query:
```json
GET _cat/fielddata/<field_name>?v
```
{% include copy-curl.html %}
If you want to get information for more than one field, separate the field names with commas:
```json
GET _cat/fielddata/field_name_1,field_name_2,field_name_3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,12 +18,14 @@ The CAT health operation lists the status of the cluster, how long the cluster h
```json
GET _cat/health?v
```
{% include copy-curl.html %}
## Path and HTTP methods
```
GET _cat/health?v
```
{% include copy-curl.html %}
## URL parameters

View File

@ -18,18 +18,21 @@ The CAT indices operation lists information related to indices—how much dis
```
GET _cat/indices?v
```
{% include copy-curl.html %}
To limit the information to a specific index, add the index name after your query.
```
GET _cat/indices/<index>?v
```
{% include copy-curl.html %}
If you want to get information for more than one index, separate the indices with commas:
```json
GET _cat/indices/index1,index2,index3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT nodeattrs operation lists the attributes of custom nodes.
```
GET _cat/nodeattrs?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -20,6 +20,7 @@ A few important node metrics are `pid`, `name`, `cluster_manager`, `ip`, `port`,
```
GET _cat/nodes?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT pending tasks operation lists the progress of all pending tasks, includi
```
GET _cat/pending_tasks?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT plugins operation lists the names, components, and versions of the insta
```
GET _cat/plugins?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The CAT recovery operation lists all completed and ongoing index and shard recov
```
GET _cat/recovery?v
```
{% include copy-curl.html %}
To see only the recoveries of a specific index, add the index name after your query.
```
GET _cat/recovery/<index>?v
```
{% include copy-curl.html %}
If you want to get information for more than one index, separate the indices with commas:
```json
GET _cat/recovery/index1,index2,index3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT repositories operation lists all completed and ongoing index and shard r
```
GET _cat/repositories?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The cat segments operation lists Lucene segment-level information for each index
```
GET _cat/segments?v
```
{% include copy-curl.html %}
To see only the information about segments of a specific index, add the index name after your query.
```
GET _cat/segments/<index>?v
```
{% include copy-curl.html %}
If you want to get information for more than one index, separate the indices with commas:
```
GET _cat/segments/index1,index2,index3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The CAT shards operation lists the state of all primary and replica shards and h
```
GET _cat/shards?v
```
{% include copy-curl.html %}
To see only the information about shards of a specific index, add the index name after your query.
```
GET _cat/shards/<index>?v
```
{% include copy-curl.html %}
If you want to get information for more than one index, separate the indices with commas:
```
GET _cat/shards/index1,index2,index3
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT snapshots operation lists all snapshots for a repository.
```
GET _cat/snapshots?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,6 +18,7 @@ The CAT tasks operation lists the progress of all tasks currently running on you
```
GET _cat/tasks?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -18,18 +18,21 @@ The CAT Templates operation lists the names, patterns, order numbers, and versio
```
GET _cat/templates?v
```
{% include copy-curl.html %}
If you want to get information for a specific template or pattern:
```
GET _cat/templates/<template_name_or_pattern>
```
{% include copy-curl.html %}
## Path and HTTP methods
```
GET _cat/templates
```
{% include copy-curl.html %}
## URL parameters

View File

@ -17,18 +17,21 @@ The CAT thread pool operation lists the active, queued, and rejected threads of
```
GET _cat/thread_pool?v
```
{% include copy-curl.html %}
If you want to get information for more than one thread pool, separate the thread pool names with commas:
```
GET _cat/thread_pool/thread_pool_name_1,thread_pool_name_2,thread_pool_name_3
```
{% include copy-curl.html %}
If you want to limit the information to a specific thread pool, add the thread pool name after your query:
```
GET _cat/thread_pool/<thread_pool_name>?v
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -21,6 +21,7 @@ To see the available operations in the CAT API, use the following command:
```
GET _cat
```
{% include copy-curl.html %}
## Optional query parameters
@ -45,6 +46,7 @@ To query aliases and get verbose output that includes all column headings in the
```json
GET _cat/aliases?v
```
{% include copy-curl.html %}
The response provides more details, such as names of each column in the response.

View File

@ -23,7 +23,7 @@ GET _cluster/allocation/explain?include_yes_decisions=true
"primary": true
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -8,7 +8,7 @@ nav_order: 16
To control the distribution of search or HTTP traffic, you can use the weights per awareness attribute to control the distribution of search or HTTP traffic across zones. This is commonly used for zonal deployments, heterogeneous instances, and routing traffic away from zones during zonal failure.
## HTTP and path methods
## Path and HTTP methods
```
PUT /_cluster/routing/awareness/<attribute>/weights
@ -50,6 +50,7 @@ The following example request creates a round robin shard allocation for search
### Request
```json
PUT /_cluster/routing/awareness/zone/weights
{
"weights":
@ -60,6 +61,8 @@ PUT /_cluster/routing/awareness/zone/weights
}
"_version" : 1
}
```
{% include copy-curl.html %}
### Response
@ -76,9 +79,10 @@ The following example request gets weights for all zones.
### Request
```
```json
GET /_cluster/routing/awareness/zone/weights
```
{% include copy-curl.html %}
### Response
@ -103,9 +107,10 @@ You can remove your weight ratio for each zone using the `DELETE` method.
### Request
```
```json
DELETE /_cluster/routing/awareness/zone/weights
```
{% include copy-curl.html %}
### Response

View File

@ -35,15 +35,17 @@ You can use the following example requests to decommission and recommission a zo
The following example request decommissions `zone-a`:
```
```json
PUT /_cluster/decommission/awareness/<zone>/<zone-a>
```
{% include copy-curl.html %}
If you want to recommission a decommissioned zone, you can use the `DELETE` method:
```
```json
DELETE /_cluster/decommission/awareness
```
{% include copy-curl.html %}
### Response
@ -60,10 +62,10 @@ The following example requests returns the decommission status of all zones.
### Request
```
```json
GET /_cluster/decommission/awareness/zone/_status
```
{% include copy-curl.html %}
### Response

View File

@ -19,6 +19,7 @@ This request waits 50 seconds for the cluster to reach the yellow status or bett
```
GET _cluster/health?wait_for_status=yellow&timeout=50s
```
{% include copy-curl.html %}
If the cluster health becomes yellow or green before 50 seconds elapse, it returns a response immediately. Otherwise it returns a response as soon as it exceeds the timeout.
@ -56,6 +57,7 @@ The following sample request retrieves cluster health for all indexes in the clu
```json
GET _cluster/health
```
{% include copy-curl.html %}
#### Sample response
@ -112,6 +114,7 @@ To check cluster health by awareness attribute (for example, zone or rack), spec
```json
GET _cluster/health?level=awareness_attributes
```
{% include copy-curl.html %}
The response contains cluster health metrics partitioned by awareness attribute:
@ -196,6 +199,7 @@ If you're interested in a particular awareness attribute, you can include the na
```json
GET _cluster/health?level=awareness_attributes&awareness_attribute=zone
```
{% include copy-curl.html %}
In response to the preceding request, OpenSearch returns cluster health information only for the `zone` awareness attribute.

View File

@ -33,6 +33,7 @@ timeout (PUT only) | Time unit | The amount of time to wait for a response from
```json
GET _cluster/settings?include_defaults=true
```
{% include copy-curl.html %}
#### Sample response
@ -114,6 +115,7 @@ PUT _cluster/settings
}
}
```
{% include copy-curl.html %}
For more information about transient settings, persistent settings, and precedence, see [OpenSearch configuration]({{site.url}}{{site.baseurl}}/install-and-configure/configuration/).

View File

@ -15,6 +15,7 @@ The cluster stats API operation returns statistics about your cluster.
```json
GET _cluster/stats/nodes/_cluster_manager
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -26,6 +26,7 @@ GET opensearch_dashboards_sample_data_logs/_count
}
}
```
{% include copy-curl.html %}
The following call to the search API produces equivalent results:
@ -41,12 +42,14 @@ GET opensearch_dashboards_sample_data_logs/_search
"track_total_hits": true
}
```
{% include copy-curl.html %}
To see the number of documents in an index:
```json
GET opensearch_dashboards_sample_data_logs/_count
```
{% include copy-curl.html %}
To check for the number of documents in a [data stream]({{site.url}}{{site.baseurl}}/opensearch/data-streams/), replace the index name with the data stream name.
@ -55,6 +58,7 @@ To see the number of documents in your cluster:
```json
GET _count
```
{% include copy-curl.html %}
Alternatively, you could use the [cat indices]({{site.url}}{{site.baseurl}}/api-reference/cat/cat-indices/) and [cat count]({{site.url}}{{site.baseurl}}/api-reference/cat/cat-count/) APIs to see the number of documents per index or data stream.
{: .note }

View File

@ -25,6 +25,7 @@ POST _bulk
{ "doc" : { "title": "World War Z" } }
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -23,6 +23,7 @@ POST sample-index1/_delete_by_query
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ If you no longer need a document in your index, you can use the delete document
```
DELETE /sample-index1/_doc/1
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ After adding a JSON document to your index, you can use the get document API ope
```json
GET sample-index1/_doc/1
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -19,6 +19,7 @@ PUT sample-index/_doc/1
"Description": "To be or not to be, that is the question."
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -31,6 +31,7 @@ GET _mget
]
}
```
{% include copy-curl.html %}
## Example of specifying index in URL
@ -50,6 +51,7 @@ GET sample-index1/_mget
]
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -24,6 +24,7 @@ POST /_reindex
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -30,6 +30,7 @@ POST test-index1/_update_by_query
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -22,6 +22,7 @@ POST /sample-index1/_update/1
}
}
```
{% include copy-curl.html %}
## Script example
@ -33,6 +34,7 @@ POST /test-index1/_update/1
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -30,6 +30,7 @@ POST opensearch_dashboards_sample_data_ecommerce/_search?explain=true
}
}
```
{% include copy-curl.html %}
More often, you want the output for a single document. In that case, specify the document ID in the URL:
@ -43,6 +44,7 @@ POST opensearch_dashboards_sample_data_ecommerce/_explain/EVz1Q3sBgg5eWQP6RSte
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -46,6 +46,7 @@ The following request clears the fields cache only:
````json
POST /my-index/_cache/clear?fielddata=true
````
{% include copy-curl.html %}
<hr />
@ -54,6 +55,7 @@ The following request clears the query cache only:
````json
POST /my-index/_cache/clear?query=true
````
{% include copy-curl.html %}
<hr />
@ -62,6 +64,7 @@ The following request clears the request cache only:
````json
POST /my-index/_cache/clear?request=true
````
{% include copy-curl.html %}
##### Clear the cache for specific fields
@ -70,6 +73,7 @@ The following request clears the fields caches of `fielda` and `fieldb`:
````json
POST /my-index/_cache/clear?fields=fielda,fieldb
````
{% include copy-curl.html %}
##### Clear caches for specific data streams and indexes
@ -78,6 +82,7 @@ The following request clears the cache for two specific indexes:
````json
POST /my-index,my-index2/_cache/clear
````
{% include copy-curl.html %}
##### Clear caches for all data streams and indexes
@ -86,6 +91,7 @@ The following request clears the cache for all data streams and indexes:
````json
POST /_cache/clear
````
{% include copy-curl.html %}
#### Sample response

View File

@ -25,6 +25,7 @@ PUT /sample-index1/_clone/cloned-index1
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ The close index API operation closes an index. Once an index is closed, you cann
```json
POST /sample-index/_close
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -56,12 +56,14 @@ The following are sample requests and a sample response.
````bash
GET /_dangling
````
{% include copy-curl.html %}
#### Sample import
````bash
POST /_dangling/msdjernajxAT23RT-BupMB?accept_data_loss=true
````
{% include copy-curl.html %}
#### Sample delete

View File

@ -16,6 +16,7 @@ If you no longer need an index, you can use the delete index API operation to de
```json
DELETE /sample-index
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ The index exists API operation returns whether or not an index already exists.
```json
HEAD /sample-index
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ You can use the get index API operation to return information about an index.
```json
GET /sample-index
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ The get settings API operation returns all the settings in your index.
```json
GET /sample-index1/_settings
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -16,6 +16,7 @@ The open index API operation opens a closed index, letting you add or search for
```json
POST /sample-index/_open
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -78,6 +78,7 @@ PUT /sample-index/_mapping
}
}
```
{% include copy-curl.html %}
#### Sample Response

View File

@ -23,6 +23,7 @@ POST /my-old-index/_shrink/my-new-index
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -25,6 +25,7 @@ PUT /sample-index1/_split/split-index1
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -24,6 +24,7 @@ PUT /sample-index1/_settings
}
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -25,6 +25,7 @@ PUT _ingest/pipeline/12345
]
}
```
{% include copy-curl.html %}
## Path and HTTP methods
```

View File

@ -14,6 +14,7 @@ If you no longer want to use an ingest pipeline, use the delete ingest pipeline
```
DELETE _ingest/pipeline/12345
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -14,6 +14,7 @@ After you create a pipeline, use the get ingest pipeline API operation to return
```
GET _ingest/pipeline/12345
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -32,6 +32,7 @@ POST /_ingest/pipeline/35678/_simulate
]
}
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -21,6 +21,7 @@ GET _msearch
{ "query": { "match_all": {} } }
```
{% include copy-curl.html %}
## Path and HTTP methods

View File

@ -50,12 +50,14 @@ To get statistics from the elected cluster manager node only, use the following
```json
GET /_nodes/_cluster_manager/stats
```
{% include copy-curl.html %}
To get statistics from nodes that are data-only nodes, use the following query:
```json
GET /_nodes/data:true/stats
```
{% include copy-curl.html %}
### Order of resolution mechanisms
@ -66,9 +68,11 @@ To get statistics from all the nodes except the cluster manager node, use the fo
```json
GET /_nodes/_all,cluster_manager:false/stats
```
{% include copy-curl.html %}
However, if you switch the resolution mechanisms, the result will include all the cluster nodes, including the cluster manager node:
```json
GET /_nodes/cluster_manager:false,_all/stats
```
```
{% include copy-curl.html %}

View File

@ -14,6 +14,7 @@ The nodes hot threads endpoint provides information about busy JVM threads for s
```json
GET /_nodes/hot_threads
```
{% include copy-curl.html %}
## Path and HTTP methods
@ -48,6 +49,7 @@ timeout | Time | Sets the time limit for node response. Default value is `30s`.
```json
GET /_nodes/hot_threads
```
{% include copy-curl.html %}
#### Sample response

View File

@ -23,12 +23,14 @@ To get information about all nodes in a cluster, use the following query:
```json
GET /_nodes
```
{% include copy-curl.html %}
To get thread pool information about the cluster manager node only, use the following query:
```json
GET /_nodes/master:true/thread_pool
```
{% include copy-curl.html %}
## Path and HTTP methods
@ -82,6 +84,7 @@ The following query requests the `process` and `transport` metrics from the clus
```json
GET /_nodes/cluster_manager:true/process,transport
```
{% include copy-curl.html %}
#### Sample response

View File

@ -41,6 +41,7 @@ The following is an example API request:
```
POST _nodes/reload_secure_settings
```
{% include copy-curl.html %}
#### Sample response

View File

@ -57,6 +57,7 @@ GET _nodes/stats/
GET _nodes/stats/_all
GET _nodes/stats/indices
```
The following index metrics are supported:
- docs
@ -80,6 +81,7 @@ For example, the following query requests statistics for `docs` and `search`:
```json
GET _nodes/stats/indices/docs,search
```
{% include copy-curl.html %}
## Query parameters
@ -100,6 +102,7 @@ include_segment_file_sizes | Boolean | If segment statistics are requested, this
```json
GET _nodes/stats/
```
{% include copy-curl.html %}
#### Sample response

View File

@ -43,6 +43,7 @@ The following request returns usage details for all nodes:
```
GET _nodes/usage
```
{% include copy-curl.html %}
#### Sample response

View File

@ -72,6 +72,7 @@ GET shakespeare/_rank_eval
]
}
````
{% include copy-curl.html %}
#### Sample response

View File

@ -34,6 +34,7 @@ The following are an example request and response.
````json
POST /shakespeare/_reload_search_analyzers
````
{% include copy-curl.html %}
#### Sample response

View File

@ -18,7 +18,7 @@ The response is more comprehensive and useful than a call to `_cluster/settings`
```
GET _remote/info
```
{% include copy-curl.html %}
## Response

View File

@ -75,6 +75,8 @@ PUT _scripts/my-first-script
}
}
````
{% include copy.html %}
The example above uses the syntax of the Dev Tools console in OpenSearch Dashboards. You can also use a curl request.
{: .note }
@ -89,6 +91,7 @@ curl -XPUT "http://opensearch:9200/_scripts/my-first-script" -H 'Content-Type: a
}
}'
````
{% include copy.html %}
See [Execute Painless stored script]({{site.url}}{{site.baseurl}}/api-reference/script-apis/exec-stored-script/) for information about running the script.

View File

@ -31,6 +31,7 @@ The following request deletes the `my-first-script` script:
````json
DELETE _scripts/my-script
````
{% include copy-curl.html %}
#### Sample response

View File

@ -40,6 +40,7 @@ GET /_scripts/painless/_execute
}
}
```
{% include copy-curl.html %}
#### Sample response
@ -94,6 +95,7 @@ PUT /testindex1
}
}
```
{% include copy-curl.html %}
Run a script to determine if a student is eligible to graduate with honors:
@ -116,6 +118,7 @@ POST /_scripts/painless/_execute
}
}
```
{% include copy-curl.html %}
The response contains the result:
@ -151,6 +154,7 @@ PUT /testindex1
}
}
```
{% include copy-curl.html %}
Run a script that converts a GPA on a 4.0 scale into a different scale that is provided as a parameter:
@ -172,6 +176,7 @@ POST /_scripts/painless/_execute
}
}
```
{% include copy-curl.html %}
The response contains the result:

View File

@ -44,6 +44,7 @@ GET books/_search
}
}
````
{% include copy-curl.html %}
#### Sample response

View File

@ -14,6 +14,7 @@ Retrieves all contexts for stored scripts.
````json
GET _script_context
````
{% include copy-curl.html %}
#### Sample response

View File

@ -14,6 +14,7 @@ The get script language API operation retrieves all supported script languages a
```json
GET _script_language
```
{% include copy-curl.html %}
#### Sample response

View File

@ -28,6 +28,7 @@ The following retrieves the `my-first-script` stored script.
````json
GET _scripts/my-first-script
````
{% include copy-curl.html %}
#### Sample response

View File

@ -25,6 +25,7 @@ GET shakespeare/_search?scroll=10m
"size": 10000
}
```
{% include copy-curl.html %}
OpenSearch caches the results and returns a scroll ID to access them in batches:
@ -41,6 +42,7 @@ GET _search/scroll
"scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAUWdmpUZDhnRFBUcWFtV21nMmFwUGJEQQ=="
}
```
{% include copy-curl.html %}
Using this scroll ID, you get results in batches of 10,000 as long as the search context is still open. Typically, the scroll ID does not change between requests, but it *can* change, so make sure to always use the latest scroll ID. If you don't send the next scroll request within the set search context, the `scroll` operation does not return any results.
@ -59,6 +61,7 @@ GET shakespeare/_search?scroll=10m
}
}
```
{% include copy-curl.html %}
With a single scroll ID, you get back 10 results.
You can have up to 10 IDs.
@ -68,12 +71,14 @@ Close the search context when youre done scrolling, because the `scroll` oper
```json
DELETE _search/scroll/DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAcWdmpUZDhnRFBUcWFtV21nMmFwUGJEQQ==
```
{% include copy-curl.html %}
To close all open scroll contexts:
```json
DELETE _search/scroll/_all
```
{% include copy-curl.html %}
The `scroll` operation corresponds to a specific timestamp. It doesn't consider documents added after that timestamp as potential results.

View File

@ -22,6 +22,7 @@ GET /movies/_search
}
}
```
{% include copy-curl.html %}
## Path and HTTP Methods

View File

@ -73,6 +73,7 @@ PUT _snapshot/my-opensearch-repo
}
}
```
{% include copy-curl.html %}
#### Sample response

View File

@ -53,6 +53,7 @@ The following request creates a snapshot called `my-first-snapshot` in an S3 rep
```json
POST _snapshot/my-s3-repository/my-first-snapshot
```
{% include copy-curl.html %}
##### Request with a body
@ -67,6 +68,7 @@ PUT _snapshot/my-s3-repository/2
"partial": false
}
```
{% include copy-curl.html %}
#### Sample responses
@ -120,6 +122,7 @@ The snapshot definition is returned.
}
}
```
#### Response fields
| Field | Data type | Description |

View File

@ -26,6 +26,7 @@ The following request deletes the `my-opensearch-repo` repository:
````json
DELETE _snapshot/my-opensearch-repo
````
{% include copy-curl.html %}
#### Sample response

View File

@ -24,9 +24,12 @@ snapshot | String | Snapshot to delete. |
#### Sample request
The following request deletes a snapshot called `my-first-snapshot` from the `my-opensearch-repo` repository.
The following request deletes a snapshot called `my-first-snapshot` from the `my-opensearch-repo` repository:
`DELETE _snapshot/my-opensearch-repo/my-first-snapshot`
```json
DELETE _snapshot/my-opensearch-repo/my-first-snapshot
```
{% include copy-curl.html %}
#### Sample response

View File

@ -34,6 +34,7 @@ The following request retrieves information for the `my-opensearch-repo` reposit
````json
GET /_snapshot/my-opensearch-repo
````
{% include copy-curl.html %}
#### Sample response

View File

@ -50,6 +50,7 @@ GET _snapshot/my-opensearch-repo/my-first-snapshot/_status
"ignore_unavailable": true
}
````
{% include copy-curl.html %}
#### Sample response

View File

@ -30,6 +30,7 @@ The following request retrieves information for the `my-first-snapshot` located
````json
GET _snapshot/my-opensearch-repo/my-first-snapshot
````
{% include copy-curl.html %}
#### Sample response

View File

@ -15,12 +15,14 @@ The following request returns information about all of your tasks:
```
GET _tasks
```
{% include copy-curl.html %}
By including a task ID, you can get information specific to a particular task. Note that a task ID consists of a node's identifying string and the task's numerical ID. For example, if your node's identifying string is `nodestring` and the task's numerical ID is `1234`, then your task ID is `nodestring:1234`. You can find this information by running the `tasks` operation:
```
GET _tasks/<task_id>
```
{% include copy-curl.html %}
Note that if a task finishes running, it won't be returned as part of your request. For an example of a task that takes a little longer to finish, you can run the [`_reindex`]({{site.url}}{{site.baseurl}}/opensearch/reindex-data) API operation on a larger document, and then run `tasks`.
@ -77,6 +79,7 @@ Note that if a task finishes running, it won't be returned as part of your reque
}
}
```
You can also use the following parameters with your query.
Parameter | Data type | Description |
@ -97,6 +100,7 @@ For example, this request returns tasks currently running on a node named `opens
```
GET /_tasks?nodes=opensearch-node1
```
{% include copy-curl.html %}
**Sample Response**
@ -149,6 +153,7 @@ The following request will return detailed information about active search tasks
```bash
curl -XGET "localhost:9200/_tasks?actions=*search&detailed
```
{% include copy.html %}
**Sample Response**
@ -203,6 +208,7 @@ After getting a list of tasks, you can cancel all cancelable tasks with the foll
```
POST _tasks/_cancel
```
{% include copy-curl.html %}
Note that not all tasks are cancelable. To see if a task is cancelable, refer to the `cancellable` field in the response to your `tasks` API request.
@ -211,12 +217,14 @@ You can also cancel a task by including a specific task ID.
```
POST _tasks/<task_id>/_cancel
```
{% include copy-curl.html %}
The `cancel` operation supports the same parameters as the `tasks` operation. The following example shows how to cancel all cancelable tasks on multiple nodes.
```
POST _tasks/_cancel?nodes=opensearch-node1,opensearch-node2
```
{% include copy-curl.html %}
## Attaching headers to tasks
@ -227,6 +235,7 @@ Usage:
```bash
curl -i -H "X-Opaque-Id: 111111" "https://localhost:9200/_tasks" -u 'admin:admin' --insecure
```
{% include copy.html %}
The `_tasks` operation returns the following result.
@ -284,4 +293,5 @@ This operation supports the same parameters as the `tasks` operation. The follow
```bash
curl -i -H "X-Opaque-Id: 123456" "https://localhost:9200/_tasks?nodes=opensearch-node1" -u 'admin:admin' --insecure
```
```
{% include copy.html %}

View File

@ -28,6 +28,7 @@ PUT movies
}
}
```
{% include copy-curl.html %}
## Parameters
@ -70,6 +71,7 @@ To use an alias in the field capabilities API, specify it in the fields paramete
```json
GET movies/_field_caps?fields=release_date
```
{% include copy-curl.html %}
## Exceptions
@ -87,3 +89,4 @@ In search and field capabilities wildcard queries, both the original field and t
```json
GET movies/_field_caps?fields=release*
```
{% include copy-curl.html %}

View File

@ -26,6 +26,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with a binary value:
@ -35,6 +36,7 @@ PUT testindex/_doc/1
"binary_value" : "bGlkaHQtd29rfx4="
}
```
{% include copy-curl.html %}
Use `=` as a padding character. Embedded newline characters are not allowed.
{: .note }

View File

@ -32,6 +32,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with Boolean values:
@ -43,6 +44,7 @@ PUT testindex/_doc/1
"c" : ""
}
```
{% include copy-curl.html %}
As a result, `a` and `b` will be set to `true`, and `c` will be set to `false`.
@ -58,6 +60,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
## Parameters
@ -100,6 +103,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
The script returns the value of `a` as `true`, `key` returns the value of `a` as `1`, and `key_as_string` returns the value of `a` as `"true"`:

View File

@ -30,6 +30,7 @@ PUT chess_store
}
}
```
{% include copy-curl.html %}
Index suggestions into OpenSearch:
@ -42,6 +43,7 @@ PUT chess_store/_doc/1
}
}
```
{% include copy-curl.html %}
## Parameters
@ -73,6 +75,7 @@ PUT chess_store/_doc/2
]
}
```
{% include copy-curl.html %}
As an alternative, you can use the following shorthand notation (note that you cannot provide the `weight` parameter in this notation):
@ -82,6 +85,7 @@ PUT chess_store/_doc/3
"suggestions" : [ "Chess clock", "Chess timer" ]
}
```
{% include copy-curl.html %}
## Querying completion field types
@ -102,6 +106,7 @@ GET chess_store/_search
}
}
```
{% include copy-curl.html %}
The response contains autocomplete suggestions:
@ -192,6 +197,7 @@ GET chess_store/_search
}
}
```
{% include copy-curl.html %}
The response contains the suggestions:
@ -297,6 +303,7 @@ GET chess_store/_search
}
}
```
{% include copy-curl.html %}
To use all default fuzziness options, specify `"fuzzy": {}` or `"fuzzy": true`.
{: .tip}
@ -330,6 +337,7 @@ GET chess_store/_search
}
}
```
{% include copy-curl.html %}
The response matches the string "abcde":

View File

@ -34,6 +34,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
## Parameters
@ -168,6 +169,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with a date:
@ -177,6 +179,7 @@ PUT testindex/_doc/21
"release_date" : "03/21/2019"
}
```
{% include copy-curl.html %}
When searching for an exact date, provide that date in the same format:
@ -192,6 +195,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
Range queries by default use the field's mapped format. You can also specify the range of dates in a different format by providing the `format` parameter:
@ -209,6 +213,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
## Date math
@ -263,6 +268,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index two documents into the index:
@ -271,12 +277,16 @@ PUT testindex/_doc/1
{
"release_date": "2022-09-14"
}
```
{% include copy-curl.html %}
```json
PUT testindex/_doc/2
{
"release_date": "2022-11-15"
}
```
{% include copy-curl.html %}
The following query searches for documents with `release_date` within 2 months and 1 day of 09/14/2022. The lower boundary of the range is rounded to the beginning of the day on 09/14/2022:
@ -293,6 +303,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
The response contains both documents:

View File

@ -27,6 +27,7 @@ PUT testindex1
}
}
```
{% include copy-curl.html %}
## Formats
@ -43,6 +44,7 @@ PUT testindex1/_doc/1
}
}
```
{% include copy-curl.html %}
- A string in the "`latitude`,`longitude`" format
@ -52,6 +54,7 @@ PUT testindex1/_doc/2
"point": "40.71,74.00"
}
```
{% include copy-curl.html %}
- A geohash
@ -61,6 +64,7 @@ PUT testindex1/_doc/3
"point": "txhxegj0uyp3"
}
```
{% include copy-curl.html %}
- An array in the [`longitude`, `latitude`] format
@ -70,6 +74,7 @@ PUT testindex1/_doc/4
"point": [74.00, 40.71]
}
```
{% include copy-curl.html %}
- A [Well-Known Text](https://docs.opengeospatial.org/is/12-063r5/12-063r5.html) POINT in the "POINT(`longitude` `latitude`)" format
@ -79,6 +84,7 @@ PUT testindex1/_doc/5
"point": "POINT (74.00 40.71)"
}
```
{% include copy-curl.html %}
- GeoJSON format, where the `coordinates` are in the [`longitude`, `latitude`] format
@ -91,6 +97,7 @@ PUT testindex1/_doc/6
}
}
```
{% include copy-curl.html %}
## Parameters

View File

@ -27,6 +27,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
## Formats
@ -68,6 +69,7 @@ PUT testindex/_doc/1
}
}
```
{% include copy-curl.html %}
Index a point in WKT format:
@ -77,6 +79,7 @@ PUT testindex/_doc/1
"location" : "POINT (74.0060 40.7128)"
}
```
{% include copy-curl.html %}
## Linestring
@ -93,6 +96,7 @@ PUT testindex/_doc/2
}
}
```
{% include copy-curl.html %}
Index a linestring in WKT format:
@ -102,6 +106,7 @@ PUT testindex/_doc/2
"location" : "LINESTRING (74.0060 40.7128, 71.0589 42.3601)"
}
```
{% include copy-curl.html %}
## Polygon
@ -126,6 +131,7 @@ PUT testindex/_doc/3
}
}
```
{% include copy-curl.html %}
Index a polygon (triangle) in WKT format:
@ -135,6 +141,7 @@ PUT testindex/_doc/3
"location" : "POLYGON ((74.0060 40.7128, 71.0589 42.3601, 73.7562 42.6526, 74.0060 40.7128))"
}
```
{% include copy-curl.html %}
The polygon may have holes inside. In this case, the `coordinates` field will contain multiple arrays. The first array represents the outer polygon, and each subsequent array represents a hole. Holes are represented as polygons and specified as arrays of coordinates.
@ -162,6 +169,7 @@ PUT testindex/_doc/4
}
}
```
{% include copy-curl.html %}
Index a polygon (triangle) with a triangular hole in WKT format:
@ -171,6 +179,7 @@ PUT testindex/_doc/4
"location" : "POLYGON ((40.7128 74.0060, 42.3601 71.0589, 42.6526 73.7562, 40.7128 74.0060), (41.7658 72.6734, 41.5623 72.6506, 41.5582 73.0515, 41.7658 72.6734))"
}
```
{% include copy-curl.html %}
In OpenSearch, you can specify a polygon by listing its vertices clockwise or counterclockwise. This works well for polygons that do not cross the date line (are narrower than 180&deg;). However, a polygon that crosses the date line (is wider than 180&deg;) might be ambiguous because WKT does not impose a specific order on vertices. Thus, you must specify polygons that cross the date line by listing their vertices counterclockwise.
@ -189,6 +198,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Subsequently indexed documents can override the `orientation` setting:
@ -207,6 +217,7 @@ PUT testindex/_doc/3
}
}
```
{% include copy-curl.html %}
## Multipoint
@ -226,6 +237,7 @@ PUT testindex/_doc/6
}
}
```
{% include copy-curl.html %}
Index a multipoint in WKT format:
@ -235,6 +247,7 @@ PUT testindex/_doc/6
"location" : "MULTIPOINT (74.0060 40.7128, 71.0589 42.3601)"
}
```
{% include copy-curl.html %}
## Multilinestring
@ -254,6 +267,7 @@ PUT testindex/_doc/2
}
}
```
{% include copy-curl.html %}
Index a linestring in WKT format:
@ -263,6 +277,7 @@ PUT testindex/_doc/2
"location" : "MULTILINESTRING ((74.0060 40.7128, 71.0589 42.3601), (73.7562 42.6526, 72.6734 41.7658))"
}
```
{% include copy-curl.html %}
## Multipolygon
@ -297,6 +312,7 @@ PUT testindex/_doc/4
}
}
```
{% include copy-curl.html %}
Index a multipolygon in WKT format:
@ -306,8 +322,7 @@ PUT testindex/_doc/4
"location" : "MULTIPOLYGON (((40.7128 74.0060, 42.3601 71.0589, 42.6526 73.7562, 40.7128 74.0060), (41.7658 72.6734, 41.5623 72.6506, 41.5582 73.0515, 41.7658 72.6734)), ((73.9776 40.7614, 73.9554 40.7827, 73.9631 40.7812, 73.9776 40.7614)))"
}
```
{% include copy-curl.html %}
## Geometry collection
@ -333,6 +348,7 @@ PUT testindex/_doc/7
}
}
```
{% include copy-curl.html %}
Index a geometry collection in WKT format:
@ -342,6 +358,7 @@ PUT testindex/_doc/7
"location" : "GEOMETRYCOLLECTION (POINT (74.0060 40.7128), LINESTRING(73.7562 42.6526, 72.6734 41.7658))"
}
```
{% include copy-curl.html %}
## Envelope
@ -358,6 +375,7 @@ PUT testindex/_doc/2
}
}
```
{% include copy-curl.html %}
In WKT format, use `BBOX (minLon, maxLon, maxLat, minLat)`.
@ -369,6 +387,7 @@ PUT testindex/_doc/8
"location" : "BBOX (71.0589, 74.0060, 42.3601, 40.7128)"
}
```
{% include copy-curl.html %}
## Parameters

View File

@ -29,6 +29,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with an IP address:
@ -38,6 +39,7 @@ PUT testindex/_doc/1
"ip_address" : "10.24.34.0"
}
```
{% include copy-curl.html %}
Query an index for a specific IP address:
@ -51,6 +53,7 @@ GET testindex/_doc/1
}
}
```
{% include copy-curl.html %}
## Searching for an IP address and its associated network mask
@ -68,6 +71,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
#### Example query in IPv6 format
@ -81,6 +85,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
If you use an IP address in IPv6 format in a `query_string` query, you need to escape `:` characters because they are parsed as special characters. You can accomplish this by wrapping the IP address in quotation marks and escaping those quotation marks with `\`.
@ -94,6 +99,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
## Parameters

View File

@ -30,6 +30,7 @@ PUT testindex1
}
}
```
{% include copy-curl.html %}
Then, index a parent document with a join field type:
@ -42,6 +43,7 @@ PUT testindex1/_doc/1
}
}
```
{% include copy-curl.html %}
You can also use a shortcut without object notation to index a parent document:
@ -52,6 +54,7 @@ PUT testindex1/_doc/1
"product_to_brand" : "brand"
}
```
{% include copy-curl.html %}
When indexing child documents, you have to specify the `routing` query parameter because parent and child documents in the same relation have to be indexed on the same shard. Each child document refers to its parent's ID in the `parent` field.
@ -66,7 +69,10 @@ PUT testindex1/_doc/3?routing=1
"parent": "1"
}
}
```
{% include copy-curl.html %}
```json
PUT testindex1/_doc/4?routing=1
{
"name": "Product 2",
@ -76,6 +82,7 @@ PUT testindex1/_doc/4?routing=1
}
}
```
{% include copy-curl.html %}
## Querying a join field
@ -91,6 +98,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The response indicates whether a document is a parent or a child:
@ -175,6 +183,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The response contains Product 1 and Product 2, which are associated with Brand 1:
@ -247,6 +256,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The response returns Brand 1 as Product 1's parent:
@ -303,6 +313,7 @@ PUT testindex1
}
}
```
{% include copy-curl.html %}
## Join field type notes

View File

@ -30,6 +30,7 @@ PUT movies
}
}
```
{% include copy-curl.html %}
## Parameters

View File

@ -26,6 +26,7 @@ PUT testindex1/_doc/100
]
}
```
{% include copy-curl.html %}
When these objects are stored, they are flattened, so their internal representation has an array of all values for each field:
@ -62,6 +63,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The query correctly returns document 100:
@ -132,6 +134,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
However, this query still incorrectly returns document 100. This is because the relation between age and smoking was lost when arrays of values for individual fields were created.
@ -151,6 +154,7 @@ PUT testindex1
}
}
```
{% include copy-curl.html %}
Then, index a document with a nested field type:
@ -163,6 +167,7 @@ PUT testindex1/_doc/100
]
}
```
{% include copy-curl.html %}
Now if you run the same query to search for patients older than 75 AND smokers, nothing is returned, which is correct.

View File

@ -45,6 +45,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with an integer value:
@ -54,6 +55,7 @@ PUT testindex/_doc/1
"integer_value" : 123
}
```
{% include copy-curl.html %}
## Scaled float field type
@ -79,6 +81,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with a scaled_float value:
@ -88,6 +91,7 @@ PUT testindex/_doc/1
"scaled" : 2.3
}
```
{% include copy-curl.html %}
The `scaled` value will be stored as 23.

View File

@ -33,6 +33,7 @@ PUT testindex1/_mappings
}
}
```
{% include copy-curl.html %}
Index a document with an object field:
@ -45,6 +46,7 @@ PUT testindex1/_doc/1
}
}
```
{% include copy-curl.html %}
Nested objects are stored as flat key/value pairs internally. To refer to a field in a nested object, use `parent field`.`child field` (for example, `patient.id`).
@ -60,6 +62,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
## Parameters
@ -92,6 +95,7 @@ PUT testindex1/_mappings
}
}
```
{% include copy-curl.html %}
Then you index a document with a new `id` field in `patient`:
@ -104,6 +108,7 @@ PUT testindex1/_doc/1
}
}
```
{% include copy-curl.html %}
As a result, the field `id` is added to the mappings:

View File

@ -38,6 +38,7 @@ PUT testindex1
}
}
```
{% include copy-curl.html %}
Index a query:
@ -68,6 +69,7 @@ PUT testindex1/_doc/1
}
}
```
{% include copy-curl.html %}
Fields referenced in the query must already exist in the mapping.
{: .note }
@ -93,6 +95,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The response contains the originally indexed query:

View File

@ -39,6 +39,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with a double range and a date range:
@ -55,6 +56,7 @@ PUT testindex/_doc/1
}
}
```
{% include copy-curl.html %}
You can use a [Term query](#term-query) or a [Range query](#range-query) to search for values within range fields.
@ -76,6 +78,7 @@ GET testindex/_search
}
}
```
{% include copy-curl.html %}
### Range query
@ -108,6 +111,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The above query will return document 1 for the `within` and `intersects` relations but will not return it for the `contains` relation.
@ -132,6 +136,7 @@ PUT testindex
}
}
```
{% include copy-curl.html %}
Index a document with IP address ranges in both formats:
@ -145,6 +150,7 @@ PUT testindex/_doc/2
"ip_address_cidr" : "10.24.34.0/24"
}
```
{% include copy-curl.html %}
## Parameters

View File

@ -45,6 +45,7 @@ PUT chessplayers
}
}
```
{% include copy-curl.html %}
Index three documents with a rank_feature field that boosts the score (`rating`) and a rank_feature field that decreases the score (`age`):
@ -55,14 +56,20 @@ PUT testindex1/_doc/1
"rating" : 2554,
"age" : 75
}
```
{% include copy-curl.html %}
```json
PUT testindex1/_doc/2
{
"name" : "Kwaku Mensah",
"rating" : 2067,
"age": 10
}
```
{% include copy-curl.html %}
```json
PUT testindex1/_doc/3
{
"name" : "Nikki Wolf",
@ -70,6 +77,7 @@ PUT testindex1/_doc/3
"age" : 22
}
```
{% include copy-curl.html %}
## Rank feature query
@ -98,6 +106,7 @@ GET chessplayers/_search
}
}
```
{% include copy-curl.html %}
When ranked by both age and rating, younger players and players who are more highly ranked score better:
@ -176,6 +185,7 @@ PUT testindex1
}
}
```
{% include copy-curl.html %}
To index a document with a rank features field, use a hashmap with string keys and positive float values:
@ -188,7 +198,10 @@ PUT testindex1/_doc/1
"teens" : 25.9
}
}
```
{% include copy-curl.html %}
```json
PUT testindex1/_doc/2
{
"correlations": {
@ -197,6 +210,7 @@ PUT testindex1/_doc/2
}
}
```
{% include copy-curl.html %}
Query the documents using a rank feature query:
@ -210,6 +224,7 @@ GET testindex1/_search
}
}
```
{% include copy-curl.html %}
The response is ranked by relevance score:

View File

@ -29,6 +29,7 @@ PUT books
}
}
```
{% include copy-curl.html %}
In addition to the `suggestions` field, this creates `suggestions._2gram`, `suggestions._3gram`, and `suggestions._index_prefix` fields.
@ -40,6 +41,7 @@ PUT books/_doc/1
"suggestions": "one two three four"
}
```
{% include copy-curl.html %}
To match terms in any order, use a bool_prefix or multi-match query. These queries rank the documents in which search terms are in the specified order higher than the documents in which terms are out of order.
@ -59,6 +61,7 @@ GET books/_search
}
}
```
{% include copy-curl.html %}
The response contains the matching document:
@ -105,6 +108,7 @@ GET books/_search
}
}
```
{% include copy-curl.html %}
The response contains the matching document:
@ -151,6 +155,7 @@ GET books/_search
}
}
```
{% include copy-curl.html %}
Response:

Some files were not shown because too many files have changed in this diff Show More