Skip to content

Commit c5de191

Browse files
committed
Add examples for get and exists APIs
1 parent f53a111 commit c5de191

File tree

12 files changed

+511
-211
lines changed

12 files changed

+511
-211
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 56 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 55 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 102 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_doc_ids/table.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ docs-delete-by-query,https://www.elastic.co/guide/en/elasticsearch/reference/{br
143143
docs-delete-by-query,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-delete-by-query.html
144144
docs-delete,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-delete.html
145145
docs-get,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-get.html
146-
docs-get,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-get.html
147146
docs-index,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-index_.html
148147
docs-multi-get,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-multi-get.html
149148
docs-multi-termvectors,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-multi-termvectors.html

specification/_global/exists/DocumentExistsRequest.ts

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,29 @@ import {
3030

3131
/**
3232
* Check a document.
33-
* Checks if a specified document exists.
33+
*
34+
* Verify that a document exists.
35+
* For example, check to see if a document with the `_id` 0 exists:
36+
*
37+
* ```
38+
* HEAD my-index-000001/_doc/0
39+
* ```
40+
*
41+
* If the document exists, the API returns a status code of `200 - OK`.
42+
* If the document doesn’t exist, the API returns `404 - Not Found`.
43+
*
44+
* **Versioning support**
45+
*
46+
* You can use the `version` parameter to check the document only if its current version is equal to the specified one.
47+
*
48+
* Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
49+
* The old version of the document doesn't disappear immediately, although you won't be able to access it.
50+
* Elasticsearch cleans up deleted documents in the background as you continue to index more data.
3451
* @rest_spec_name exists
3552
* @availability stack stability=stable
3653
* @availability serverless stability=stable visibility=public
3754
* @doc_tag document
55+
* @doc_id docs-get
3856
*/
3957
export interface Request extends RequestBase {
4058
urls: [
@@ -45,19 +63,24 @@ export interface Request extends RequestBase {
4563
]
4664
path_parts: {
4765
/**
48-
* Identifier of the document.
66+
* A unique document identifier.
4967
*/
5068
id: Id
5169
/**
52-
* Comma-separated list of data streams, indices, and aliases.
53-
* Supports wildcards (`*`).
70+
* A comma-separated list of data streams, indices, and aliases.
71+
* It supports wildcards (`*`).
5472
*/
5573
index: IndexName
5674
}
5775
query_parameters: {
5876
/**
59-
* Specifies the node or shard the operation should be performed on.
60-
* Random by default.
77+
* The node or shard the operation should be performed on.
78+
* By default, the operation is randomized between the shard replicas.
79+
*
80+
* If it is set to `_local`, the operation will prefer to be run on a local allocated shard when possible.
81+
* If it is set to a custom value, the value is used to guarantee that the same shards will be used for the same custom value.
82+
* This can help with "jumping values" when hitting different shards in different refresh states.
83+
* A sample value can be something like the web session ID or the user name.
6184
*/
6285
preference?: string
6386
/**
@@ -67,31 +90,37 @@ export interface Request extends RequestBase {
6790
*/
6891
realtime?: boolean
6992
/**
70-
* If `true`, Elasticsearch refreshes all shards involved in the delete by query after the request completes.
93+
* If `true`, the request refreshes the relevant shards before retrieving the document.
94+
* Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
7195
* @server_default false
7296
*/
7397
refresh?: boolean
7498
/**
75-
* Target the specified primary shard.
76-
* @doc_id routing
99+
* A custom value used to route operations to a specific shard.
100+
* @ext_doc_id routing
77101
*/
78102
routing?: Routing
79103
/**
80-
* `true` or `false` to return the `_source` field or not, or a list of fields to return.
104+
* Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
81105
*/
82106
_source?: SourceConfigParam
83107
/**
84-
* A comma-separated list of source fields to exclude in the response.
108+
* A comma-separated list of source fields to exclude from the response.
109+
* You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
110+
* If the `_source` parameter is `false`, this parameter is ignored.
85111
*/
86112
_source_excludes?: Fields
87113
/**
88114
* A comma-separated list of source fields to include in the response.
115+
* If this parameter is specified, only these source fields are returned.
116+
* You can exclude fields from this subset using the `_source_excludes` query parameter.
117+
* If the `_source` parameter is `false`, this parameter is ignored.
89118
*/
90119
_source_includes?: Fields
91120
/**
92-
* List of stored fields to return as part of a hit.
121+
* A comma-separated list of stored fields to return as part of a hit.
93122
* If no fields are specified, no stored fields are included in the response.
94-
* If this field is specified, the `_source` parameter defaults to false.
123+
* If this field is specified, the `_source` parameter defaults to `false`.
95124
*/
96125
stored_fields?: Fields
97126
/**
@@ -100,7 +129,7 @@ export interface Request extends RequestBase {
100129
*/
101130
version?: VersionNumber
102131
/**
103-
* Specific version type: `external`, `external_gte`.
132+
* The version type.
104133
*/
105134
version_type?: VersionType
106135
}

specification/_global/exists_source/SourceExistsRequest.ts

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,22 @@ import {
3030

3131
/**
3232
* Check for a document source.
33-
* Checks if a document's `_source` is stored.
33+
*
34+
* Check whether a document source exists in an index.
35+
* For example:
36+
*
37+
* ```
38+
* HEAD my-index-000001/_source/1
39+
* ```
40+
*
41+
* A document's source is not available if it is disabled in the mapping.
3442
* @rest_spec_name exists_source
3543
* @availability stack since=5.4.0 stability=stable
3644
* @availability serverless stability=stable visibility=public
3745
* @doc_tag document
46+
* @index_privileges read
47+
* @doc_id docs-get
48+
* @ext_doc_id mapping-source-field
3849
*/
3950
export interface Request extends RequestBase {
4051
urls: [
@@ -45,39 +56,40 @@ export interface Request extends RequestBase {
4556
]
4657
path_parts: {
4758
/**
48-
* Identifier of the document.
59+
* A unique identifier for the document.
4960
*/
5061
id: Id
5162
/**
52-
* Comma-separated list of data streams, indices, and aliases.
53-
* Supports wildcards (`*`).
63+
* A comma-separated list of data streams, indices, and aliases.
64+
* It supports wildcards (`*`).
5465
*/
5566
index: IndexName
5667
}
5768
query_parameters: {
5869
/**
59-
* Specifies the node or shard the operation should be performed on.
60-
* Random by default.
70+
* The node or shard the operation should be performed on.
71+
* By default, the operation is randomized between the shard replicas.
6172
*/
6273
preference?: string
6374
/**
64-
* If true, the request is real-time as opposed to near-real-time.
75+
* If `true`, the request is real-time as opposed to near-real-time.
6576
* @server_default true
66-
* @doc_id realtime
77+
* @ext_doc_id realtime
6778
*/
6879
realtime?: boolean
6980
/**
70-
* If `true`, Elasticsearch refreshes all shards involved in the delete by query after the request completes.
81+
* If `true`, the request refreshes the relevant shards before retrieving the document.
82+
* Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
7183
* @server_default false
7284
*/
7385
refresh?: boolean
7486
/**
75-
* Target the specified primary shard.
76-
* @doc_id routing
87+
* A custom value used to route operations to a specific shard.
88+
* @ext_doc_id routing
7789
*/
7890
routing?: Routing
7991
/**
80-
* `true` or `false` to return the `_source` field or not, or a list of fields to return.
92+
* Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
8193
*/
8294
_source?: SourceConfigParam
8395
/**
@@ -89,12 +101,12 @@ export interface Request extends RequestBase {
89101
*/
90102
_source_includes?: Fields
91103
/**
92-
* Explicit version number for concurrency control.
93-
* The specified version must match the current version of the document for the request to succeed.
104+
* The version number for concurrency control.
105+
* It must match the current version of the document for the request to succeed.
94106
*/
95107
version?: VersionNumber
96108
/**
97-
* Specific version type: `external`, `external_gte`.
109+
* The version type.
98110
*/
99111
version_type?: VersionType
100112
}

specification/_global/get/GetRequest.ts

Lines changed: 89 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,69 @@ import {
3030

3131
/**
3232
* Get a document by its ID.
33-
* Retrieves the document with the specified ID from an index.
33+
*
34+
* Get a document and its source or stored fields from an index.
35+
*
36+
* By default, this API is realtime and is not affected by the refresh rate of the index (when data will become visible for search).
37+
* In the case where stored fields are requested with the `stored_fields` parameter and the document has been updated but is not yet refreshed, the API will have to parse and analyze the source to extract the stored fields.
38+
* To turn off realtime behavior, set the `realtime` parameter to false.
39+
*
40+
* **Source filtering**
41+
*
42+
* By default, the API returns the contents of the `_source` field unless you have used the `stored_fields` parameter or the `_source` field is turned off.
43+
* You can turn off `_source` retrieval by using the `_source` parameter:
44+
*
45+
* ```
46+
* GET my-index-000001/_doc/0?_source=false
47+
* ```
48+
*
49+
* If you only need one or two fields from the `_source`, use the `_source_includes` or `_source_excludes` parameters to include or filter out particular fields.
50+
* This can be helpful with large documents where partial retrieval can save on network overhead
51+
* Both parameters take a comma separated list of fields or wildcard expressions.
52+
* For example:
53+
*
54+
* ```
55+
* GET my-index-000001/_doc/0?_source_includes=*.id&_source_excludes=entities
56+
* ```
57+
*
58+
* If you only want to specify includes, you can use a shorter notation:
59+
*
60+
* ```
61+
* GET my-index-000001/_doc/0?_source=*.id
62+
* ```
63+
*
64+
* **Routing**
65+
*
66+
* If routing is used during indexing, the routing value also needs to be specified to retrieve a document.
67+
* For example:
68+
*
69+
* ```
70+
* GET my-index-000001/_doc/2?routing=user1
71+
* ```
72+
*
73+
* This request gets the document with ID 2, but it is routed based on the user.
74+
* The document is not fetched if the correct routing is not specified.
75+
*
76+
* **Distributed**
77+
*
78+
* The GET operation is hashed into a specific shard ID.
79+
* It is then redirected to one of the replicas within that shard ID and returns the result.
80+
* The replicas are the primary shard and its replicas within that shard ID group.
81+
* This means that the more replicas you have, the better your GET scaling will be.
82+
*
83+
* **Versioning support**
84+
*
85+
* You can use the `version` parameter to retrieve the document only if its current version is equal to the specified one.
86+
*
87+
* Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
88+
* The old version of the document doesn't disappear immediately, although you won't be able to access it.
89+
* Elasticsearch cleans up deleted documents in the background as you continue to index more data.
3490
* @rest_spec_name get
3591
* @availability stack stability=stable
3692
* @availability serverless stability=stable visibility=public
93+
* @index_privileges read
3794
* @doc_tag document
95+
* @doc_id docs-get
3896
*/
3997
export interface Request extends RequestBase {
4098
urls: [
@@ -44,21 +102,27 @@ export interface Request extends RequestBase {
44102
}
45103
]
46104
path_parts: {
47-
/** Unique identifier of the document. */
105+
/** A unique document identifier. */
48106
id: Id
49-
/** Name of the index that contains the document. */
107+
/** The name of the index that contains the document. */
50108
index: IndexName
51109
}
52110
query_parameters: {
53111
/**
54-
* Should this request force synthetic _source?
55-
* Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance.
56-
* Fetches with this enabled will be slower the enabling synthetic source natively in the index.
112+
* Indicates whether the request forces synthetic `_source`.
113+
* Use this paramater to test if the mapping supports synthetic `_source` and to get a sense of the worst case performance.
114+
* Fetches with this parameter enabled will be slower than enabling synthetic source natively in the index.
57115
* @availability stack since=8.4.0 visibility=feature_flag feature_flag=es.index_mode_feature_flag_registered
58116
*/
59117
force_synthetic_source?: boolean
60118
/**
61-
* Specifies the node or shard the operation should be performed on. Random by default.
119+
* The node or shard the operation should be performed on.
120+
* By default, the operation is randomized between the shard replicas.
121+
*
122+
* If it is set to `_local`, the operation will prefer to be run on a local allocated shard when possible.
123+
* If it is set to a custom value, the value is used to guarantee that the same shards will be used for the same custom value.
124+
* This can help with "jumping values" when hitting different shards in different refresh states.
125+
* A sample value can be something like the web session ID or the user name.
62126
*/
63127
preference?: string
64128
/**
@@ -68,39 +132,48 @@ export interface Request extends RequestBase {
68132
*/
69133
realtime?: boolean
70134
/**
71-
* If true, Elasticsearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes.
135+
* If `true`, the request refreshes the relevant shards before retrieving the document.
136+
* Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
72137
* @server_default false
73138
*/
74139
refresh?: boolean
75140
/**
76-
* Target the specified primary shard.
77-
* @doc_id routing
141+
* A custom value used to route operations to a specific shard.
142+
* @ext_doc_id routing
78143
*/
79144
routing?: Routing
80145
/**
81-
* True or false to return the _source field or not, or a list of fields to return.
146+
* Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
82147
*/
83148
_source?: SourceConfigParam
84149
/**
85-
* A comma-separated list of source fields to exclude in the response.
150+
* A comma-separated list of source fields to exclude from the response.
151+
* You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
152+
* If the `_source` parameter is `false`, this parameter is ignored.
86153
*/
87154
_source_excludes?: Fields
88155
/**
89156
* A comma-separated list of source fields to include in the response.
157+
* If this parameter is specified, only these source fields are returned.
158+
* You can exclude fields from this subset using the `_source_excludes` query parameter.
159+
* If the `_source` parameter is `false`, this parameter is ignored.
90160
*/
91161
_source_includes?: Fields
92162
/**
93-
* List of stored fields to return as part of a hit.
163+
* A comma-separated list of stored fields to return as part of a hit.
94164
* If no fields are specified, no stored fields are included in the response.
95-
* If this field is specified, the `_source` parameter defaults to false.
165+
* If this field is specified, the `_source` parameter defaults to `false`.
166+
* Only leaf fields can be retrieved with the `stored_field` option.
167+
* Object fields can't be returned;​if specified, the request fails.
96168
*/
97169
stored_fields?: Fields
98170
/**
99-
* Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
171+
* The version number for concurrency control.
172+
* It must match the current version of the document for the request to succeed.
100173
*/
101174
version?: VersionNumber
102175
/**
103-
* Specific version type: internal, external, external_gte.
176+
* The version type.
104177
*/
105178
version_type?: VersionType
106179
}

0 commit comments

Comments
 (0)