Skip to content

Commit 9b3c186

Browse files
authored
[DOCS] Add examples for mget, msearch template APIs (#3615)
1 parent fbd1f0d commit 9b3c186

34 files changed

+1025
-260
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 61 additions & 48 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: 52 additions & 39 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: 114 additions & 89 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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ logstash-centralized-pipeline-management,https://www.elastic.co/guide/en/logstas
300300
logstash-configuration-file-structure,https://www.elastic.co/guide/en/logstash/{branch}/configuration-file-structure.html
301301
logstash-logstash-settings-file,https://www.elastic.co/guide/en/logstash/{branch}/logstash-settings-file.html
302302
lowercase-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/lowercase-processor.html
303+
mapbox-vector-tile,https://github.com/mapbox/vector-tile-spec/blob/master/README.md
303304
mapping-date-format,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/mapping-date-format.html
304305
mapping-meta-field,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/mapping-meta-field.html
305306
mapping-params,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/mapping-params.html
@@ -516,6 +517,7 @@ script-delete,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/d
516517
script-languages,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/get-script-languages-api.html
517518
script-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/script-processor.html
518519
script-put,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/create-stored-script-api.html
520+
scroll-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/scroll-api.html
519521
scroll-search-results,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/paginate-search-results.html#scroll-search-results
520522
search-after,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/paginate-search-results.html#search-after
521523
search-aggregations,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-aggregations.html
@@ -604,8 +606,9 @@ search-render-query,https://www.elastic.co/guide/en/elasticsearch/reference/{bra
604606
search-count,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-count.html
605607
search-explain,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-explain.html
606608
search-field-caps,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-field-caps.html
609+
search-knn,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/knn-search-api.html
607610
search-multi-search,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-multi-search.html
608-
search-multi-search,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-multi-search.html
611+
search-multi-search-template,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/multi-search-template.html
609612
search-rank-eval,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-rank-eval.html
610613
search-rank-eval,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-rank-eval.html
611614
search-request-body,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-request-body.html

specification/_global/field_caps/FieldCapabilitiesRequest.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { QueryContainer } from '@_types/query_dsl/abstractions'
3535
* @availability serverless stability=stable visibility=public
3636
* @index_privileges view_index_metadata,read
3737
* @doc_tag search
38+
* @doc_id search-field-caps
3839
*/
3940
export interface Request extends RequestBase {
4041
urls: [
@@ -49,7 +50,7 @@ export interface Request extends RequestBase {
4950
]
5051
path_parts: {
5152
/**
52-
* Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.
53+
* A comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.
5354
*/
5455
index?: Indices
5556
}
@@ -62,12 +63,12 @@ export interface Request extends RequestBase {
6263
*/
6364
allow_no_indices?: boolean
6465
/**
65-
* Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
66+
* The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
6667
* @server_default open
6768
*/
6869
expand_wildcards?: ExpandWildcards
6970
/**
70-
* Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
71+
* A comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
7172
*/
7273
fields?: Fields
7374
/**
@@ -81,11 +82,15 @@ export interface Request extends RequestBase {
8182
*/
8283
include_unmapped?: boolean
8384
/**
85+
* A comma-separated list of filters to apply to the response.
8486
* @availability stack since=8.2.0
8587
* @availability serverless
8688
*/
8789
filters?: string
8890
/**
91+
* A comma-separated list of field types to include.
92+
* Any fields that do not match one of these types will be excluded from the results.
93+
* It defaults to empty, meaning that all field types are returned.
8994
* @availability stack since=8.2.0
9095
* @availability serverless
9196
*/
@@ -100,17 +105,21 @@ export interface Request extends RequestBase {
100105
}
101106
body: {
102107
/**
103-
* List of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
108+
* A list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
104109
* @availability stack since=8.5.0
105110
* @availability serverless
106111
*/
107112
fields?: Fields
108113
/**
109-
* Allows to filter indices if the provided query rewrites to match_none on every shard.
114+
* Filter indices if the provided query rewrites to `match_none` on every shard.
115+
*
116+
* IMPORTANT: The filtering is done on a best-effort basis, it uses index statistics and mappings to rewrite queries to `match_none` instead of fully running the request.
117+
* For instance a range query over a date field can rewrite to `match_none` if all documents within a shard (including deleted documents) are outside of the provided range.
118+
* However, not all queries can rewrite to `match_none` so this API may return an index even if the provided filter matches no document.
110119
*/
111120
index_filter?: QueryContainer
112121
/**
113-
* Defines ad-hoc runtime fields in the request similar to the way it is done in search requests.
122+
* Define ad-hoc runtime fields in the request similar to the way it is done in search requests.
114123
* These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.
115124
* @doc_id runtime-search-request
116125
* @availability stack since=7.12.0

specification/_global/field_caps/FieldCapabilitiesResponse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import { FieldCapability } from './types'
2929
*/
3030
export class Response {
3131
body: {
32+
/**
33+
* The list of indices where this field has the same type family, or null if all indices have the same type family for the field.
34+
*/
3235
indices: Indices
3336
fields: Dictionary<Field, Dictionary<string, FieldCapability>>
3437
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# summary:
2+
# method_request: "POST my-index-*/_field_caps?fields=rating"
3+
description: >
4+
Run `POST my-index-*/_field_caps?fields=rating` to get field capabilities and filter indices with a query.
5+
Indices that rewrite the provided filter to `match_none` on every shard will be filtered from the response.
6+
# type: "request"
7+
value: |-
8+
{
9+
"index_filter": {
10+
"range": {
11+
"@timestamp": {
12+
"gte": "2018"
13+
}
14+
}
15+
}
16+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
summary: Get two fields
2+
# type: "response"
3+
description: >
4+
A successful response from `GET _field_caps?fields=rating,title`.
5+
The field `rating` is defined as a long in `index1` and `index2` and as a `keyword` in `index3` and `index4`.
6+
The field `rating` is not aggregatable in `index1`.
7+
The field `rating` is not searchable in `index4`.
8+
The field `title` is defined as text in all indices.
9+
# response_code: 200,
10+
value: |-
11+
{
12+
"indices": [ "index1", "index2", "index3", "index4", "index5" ],
13+
"fields": {
14+
"rating": {
15+
"long": {
16+
"metadata_field": false,
17+
"searchable": true,
18+
"aggregatable": false,
19+
"indices": [ "index1", "index2" ],
20+
"non_aggregatable_indices": [ "index1" ]
21+
},
22+
"keyword": {
23+
"metadata_field": false,
24+
"searchable": false,
25+
"aggregatable": true,
26+
"indices": [ "index3", "index4" ],
27+
"non_searchable_indices": [ "index4" ]
28+
}
29+
},
30+
"title": {
31+
"text": {
32+
"metadata_field": false,
33+
"searchable": true,
34+
"aggregatable": false
35+
}
36+
}
37+
}
38+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
summary: Get unmapped fields
2+
# type: "response"
3+
description: >
4+
A successful response from `GET _field_caps?fields=rating,title&include_unmapped`.
5+
The response contains an entry for each field that is present in some indices but not all.
6+
For example, the `rating` and `title` fields are unmapped in `index5`.
7+
# response_code: 200,
8+
value: |-
9+
{
10+
"indices": [ "index1", "index2", "index3", "index4", "index5" ],
11+
"fields": {
12+
"rating": {
13+
"long": {
14+
"metadata_field": false,
15+
"searchable": true,
16+
"aggregatable": false,
17+
"indices": [ "index1", "index2" ],
18+
"non_aggregatable_indices": [ "index1" ]
19+
},
20+
"keyword": {
21+
"metadata_field": false,
22+
"searchable": false,
23+
"aggregatable": true,
24+
"indices": [ "index3", "index4" ],
25+
"non_searchable_indices": [ "index4" ]
26+
}
27+
},
28+
"title": {
29+
"text": {
30+
"metadata_field": false,
31+
"searchable": true,
32+
"aggregatable": false
33+
}
34+
}
35+
}
36+
}

specification/_global/knn_search/KnnSearchRequest.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@ import { Query } from './_types/Knn'
3737
*
3838
* The kNN search API supports restricting the search using a filter.
3939
* The search will return the top k documents that also match the filter query.
40+
*
41+
* A kNN search response has the exact same structure as a search API response.
42+
* However, certain sections have a meaning specific to kNN search:
43+
*
44+
* * The document `_score` is determined by the similarity between the query and document vector.
45+
* * The `hits.total` object contains the total number of nearest neighbor candidates considered, which is `num_candidates * num_shards`. The `hits.total.relation` will always be `eq`, indicating an exact value.
4046
* @rest_spec_name knn_search
4147
* @availability stack since=8.0.0 stability=experimental
4248
* @deprecated 8.4.0 The kNN search API has been replaced by the `knn` option in the search API.
4349
* @doc_tag search
50+
* @doc_id search-knn
4451
*/
4552
export interface Request extends RequestBase {
4653
urls: [
@@ -52,49 +59,52 @@ export interface Request extends RequestBase {
5259
path_parts: {
5360
/**
5461
* A comma-separated list of index names to search;
55-
* use `_all` or to perform the operation on all indices
62+
* use `_all` or to perform the operation on all indices.
5663
*/
5764
index: Indices
5865
}
5966
query_parameters: {
6067
/**
61-
* A comma-separated list of specific routing values
68+
* A comma-separated list of specific routing values.
6269
*/
6370
routing?: Routing
6471
}
6572
body: {
6673
/**
6774
* Indicates which source fields are returned for matching documents. These
68-
* fields are returned in the hits._source property of the search response.
75+
* fields are returned in the `hits._source` property of the search response.
76+
* @server_default true
6977
*/
7078
_source?: SourceConfig
7179
/**
7280
* The request returns doc values for field names matching these patterns
73-
* in the hits.fields property of the response. Accepts wildcard (*) patterns.
81+
* in the `hits.fields` property of the response.
82+
* It accepts wildcard (`*`) patterns.
7483
*/
7584
docvalue_fields?: FieldAndFormat[]
7685
/**
77-
* List of stored fields to return as part of a hit. If no fields are specified,
78-
* no stored fields are included in the response. If this field is specified, the _source
79-
* parameter defaults to false. You can pass _source: true to return both source fields
86+
* A list of stored fields to return as part of a hit. If no fields are specified,
87+
* no stored fields are included in the response. If this field is specified, the `_source`
88+
* parameter defaults to `false`. You can pass `_source: true` to return both source fields
8089
* and stored fields in the search response.
8190
*/
8291
stored_fields?: Fields
8392
/**
8493
* The request returns values for field names matching these patterns
85-
* in the hits.fields property of the response. Accepts wildcard (*) patterns.
94+
* in the `hits.fields` property of the response.
95+
* It accepts wildcard (`*`) patterns.
8696
*/
8797
fields?: Fields
8898
/**
89-
* Query to filter the documents that can match. The kNN search will return the top
99+
* A query to filter the documents that can match. The kNN search will return the top
90100
* `k` documents that also match this filter. The value can be a single query or a
91101
* list of queries. If `filter` isn't provided, all documents are allowed to match.
92102
* @availability stack since=8.2.0
93103
* @availability serverless
94104
*/
95105
filter?: QueryContainer | QueryContainer[]
96106
/**
97-
* kNN query to execute
107+
* The kNN query to run.
98108
* @ext_doc_id query-dsl-knn-query
99109
*/
100110
knn: Query

0 commit comments

Comments
 (0)