Skip to content

Commit 3b8aafa

Browse files
committed
[DOCS] Add examples and descriptions for explain, termvector, search APIs (#3614)
(cherry picked from commit 52b4f94)
1 parent defa610 commit 3b8aafa

28 files changed

+835
-225
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 61 additions & 58 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: 54 additions & 51 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: 119 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

Lines changed: 1 addition & 0 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ search-request-body,https://www.elastic.co/guide/en/elasticsearch/reference/{bra
596596
search-search,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-search.html
597597
search-shards,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-shards.html
598598
search-template,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-template.html
599+
search-template-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-template-api.html
599600
search-terms-enum,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-terms-enum.html
600601
search-validate,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-validate.html
601602
search-vector-tile-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-vector-tile-api.html

specification/_global/explain/ExplainRequest.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,76 +25,88 @@ import { Operator } from '@_types/query_dsl/Operator'
2525

2626
/**
2727
* Explain a document match result.
28-
* Returns information about why a specific document matches, or doesn’t match, a query.
28+
* Get information about why a specific document matches, or doesn't match, a query.
29+
* It computes a score explanation for a query and a specific document.
2930
* @rest_spec_name explain
3031
* @availability stack stability=stable
3132
* @availability serverless stability=stable visibility=public
33+
* @index_privileges read
3234
* @doc_tag search
35+
* @doc_id search-explain
3336
*/
3437
export interface Request extends RequestBase {
3538
path_parts: {
3639
/**
37-
* Defines the document ID.
40+
* The document identifier.
3841
*/
3942
id: Id
4043
/**
41-
* Index names used to limit the request.
44+
* Index names that are used to limit the request.
4245
* Only a single index name can be provided to this parameter.
4346
*/
4447
index: IndexName
4548
}
4649
query_parameters: {
4750
/**
48-
* Analyzer to use for the query string.
49-
* This parameter can only be used when the `q` query string parameter is specified.
51+
* The analyzer to use for the query string.
52+
* This parameter can be used only when the `q` query string parameter is specified.
5053
*/
5154
analyzer?: string
5255
/**
5356
* If `true`, wildcard and prefix queries are analyzed.
57+
* This parameter can be used only when the `q` query string parameter is specified.
5458
* @server_default false
5559
*/
5660
analyze_wildcard?: boolean
5761
/**
5862
* The default operator for query string query: `AND` or `OR`.
63+
* This parameter can be used only when the `q` query string parameter is specified.
5964
* @server_default OR
6065
*/
6166
default_operator?: Operator
6267
/**
63-
* Field to use as default where no field prefix is given in the query string.
68+
* The field to use as default where no field prefix is given in the query string.
69+
* This parameter can be used only when the `q` query string parameter is specified.
6470
*/
6571
df?: string
6672
/**
6773
* If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
74+
* This parameter can be used only when the `q` query string parameter is specified.
6875
* @server_default false
6976
*/
7077
lenient?: boolean
7178
/**
72-
* Specifies the node or shard the operation should be performed on.
73-
* Random by default.
79+
* The node or shard the operation should be performed on.
80+
* It is random by default.
7481
*/
7582
preference?: string
7683
/**
77-
* Custom value used to route operations to a specific shard.
84+
* A custom value used to route operations to a specific shard.
7885
*/
7986
routing?: Routing
8087
/**
81-
* True or false to return the `_source` field or not, or a list of fields to return.
88+
* `True` or `false` to return the `_source` field or not or a list of fields to return.
8289
*/
8390
_source?: SourceConfigParam
8491
/**
8592
* A comma-separated list of source fields to exclude from the response.
93+
* You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
94+
* If the `_source` parameter is `false`, this parameter is ignored.
8695
*/
8796
_source_excludes?: Fields
8897
/**
8998
* A comma-separated list of source fields to include in the response.
99+
* If this parameter is specified, only these source fields are returned.
100+
* You can exclude fields from this subset using the `_source_excludes` query parameter.
101+
* If the `_source` parameter is `false`, this parameter is ignored.
90102
*/
91103
_source_includes?: Fields
92104
/**
93105
* A comma-separated list of stored fields to return in the response.
94106
*/
95107
stored_fields?: Fields
96108
/**
97-
* Query in the Lucene query string syntax.
109+
* The query in the Lucene query string syntax.
98110
*/
99111
q?: string
100112
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# summary:
2+
# method_request: GET /my-index-000001/_explain/0
3+
description: >
4+
Run `GET /my-index-000001/_explain/0` with the request body.
5+
Alternatively, run `GET /my-index-000001/_explain/0?q=message:elasticsearch`
6+
# type: request
7+
value: |-
8+
{
9+
"query" : {
10+
"match" : { "message" : "elasticsearch" }
11+
}
12+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# summary:
2+
description: A successful response from `GET /my-index-000001/_explain/0`.
3+
# type: response
4+
# response_code: 200
5+
value: |-
6+
{
7+
"_index":"my-index-000001",
8+
"_id":"0",
9+
"matched":true,
10+
"explanation":{
11+
"value":1.6943598,
12+
"description":"weight(message:elasticsearch in 0) [PerFieldSimilarity], result of:",
13+
"details":[
14+
{
15+
"value":1.6943598,
16+
"description":"score(freq=1.0), computed as boost * idf * tf from:",
17+
"details":[
18+
{
19+
"value":2.2,
20+
"description":"boost",
21+
"details":[]
22+
},
23+
{
24+
"value":1.3862944,
25+
"description":"idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
26+
"details":[
27+
{
28+
"value":1,
29+
"description":"n, number of documents containing term",
30+
"details":[]
31+
},
32+
{
33+
"value":5,
34+
"description":"N, total number of documents with field",
35+
"details":[]
36+
}
37+
]
38+
},
39+
{
40+
"value":0.5555556,
41+
"description":"tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:",
42+
"details":[
43+
{
44+
"value":1.0,
45+
"description":"freq, occurrences of term within document",
46+
"details":[]
47+
},
48+
{
49+
"value":1.2,
50+
"description":"k1, term saturation parameter",
51+
"details":[]
52+
},
53+
{
54+
"value":0.75,
55+
"description":"b, length normalization parameter",
56+
"details":[]
57+
},
58+
{
59+
"value":3.0,
60+
"description":"dl, length of field",
61+
"details":[]
62+
},
63+
{
64+
"value":5.4,
65+
"description":"avgdl, average length of field",
66+
"details":[]
67+
}
68+
]
69+
}
70+
]
71+
}
72+
]
73+
}
74+
}

specification/_global/mtermvectors/MultiTermVectorsRequest.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,30 @@ import { Operation } from './types'
3131
/**
3232
* Get multiple term vectors.
3333
*
34+
* Get multiple term vectors with a single request.
3435
* You can specify existing documents by index and ID or provide artificial documents in the body of the request.
3536
* You can specify the index in the request body or request URI.
3637
* The response contains a `docs` array with all the fetched termvectors.
3738
* Each element has the structure provided by the termvectors API.
3839
* @rest_spec_name mtermvectors
3940
* @availability stack stability=stable
4041
* @availability serverless stability=stable visibility=public
42+
* @index_privileges read
4143
* @doc_tag document
44+
* @doc_id docs-multi-termvectors
4245
*/
4346
export interface Request extends RequestBase {
4447
path_parts: {
4548
/**
46-
* Name of the index that contains the documents.
49+
* The name of the index that contains the documents.
4750
*/
4851
index?: IndexName
4952
}
5053
query_parameters: {
5154
ids?: Id[]
5255
/**
53-
* Comma-separated list or wildcard expressions of fields to include in the statistics.
54-
* Used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters.
56+
* A comma-separated list or wildcard expressions of fields to include in the statistics.
57+
* It is used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters.
5558
*/
5659
fields?: Fields
5760
/**
@@ -75,8 +78,8 @@ export interface Request extends RequestBase {
7578
*/
7679
positions?: boolean
7780
/**
78-
* Specifies the node or shard the operation should be performed on.
79-
* Random by default.
81+
* The node or shard the operation should be performed on.
82+
* It is random by default.
8083
*/
8184
preference?: string
8285
/**
@@ -86,7 +89,7 @@ export interface Request extends RequestBase {
8689
*/
8790
realtime?: boolean
8891
/**
89-
* Custom value used to route operations to a specific shard.
92+
* A custom value used to route operations to a specific shard.
9093
*/
9194
routing?: Routing
9295
/**
@@ -99,17 +102,17 @@ export interface Request extends RequestBase {
99102
*/
100103
version?: VersionNumber
101104
/**
102-
* Specific version type.
105+
* The version type.
103106
*/
104107
version_type?: VersionType
105108
}
106109
body: {
107110
/**
108-
* Array of existing or artificial documents.
111+
* An array of existing or artificial documents.
109112
*/
110113
docs?: Operation[]
111114
/**
112-
* Simplified syntax to specify documents by their ID if they're in the same index.
115+
* A simplified syntax to specify documents by their ID if they're in the same index.
113116
*/
114117
ids?: Id[]
115118
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
summary: Get multi term vectors
2+
# method_request: POST /my-index-000001/_mtermvectors
3+
description: >
4+
Run `POST /my-index-000001/_mtermvectors`.
5+
If you specify an index in the request URI, the index does not need to be specified for each documents in the request body.
6+
# type: request
7+
value: |-
8+
{
9+
"docs": [
10+
{
11+
"_id": "2",
12+
"fields": [
13+
"message"
14+
],
15+
"term_statistics": true
16+
},
17+
{
18+
"_id": "1"
19+
}
20+
]
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
summary: Simplified syntax
2+
# method_request: POST /my-index-000001/_mtermvectors
3+
description: >
4+
Run `POST /my-index-000001/_mtermvectors`.
5+
If all requested documents are in same index and the parameters are the same, you can use a simplified syntax.
6+
# type: request
7+
value: |-
8+
{
9+
"ids": [ "1", "2" ],
10+
"parameters": {
11+
"fields": [
12+
"message"
13+
],
14+
"term_statistics": true
15+
}
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
summary: Artificial documents
2+
# method_request: POST /_mtermvectors
3+
description: >
4+
Run `POST /_mtermvectors` to generate term vectors for artificial documents provided in the body of the request.
5+
The mapping used is determined by the specified `_index`.
6+
# type: request
7+
value: |-
8+
{
9+
"docs": [
10+
{
11+
"_index": "my-index-000001",
12+
"doc" : {
13+
"message" : "test test test"
14+
}
15+
},
16+
{
17+
"_index": "my-index-000001",
18+
"doc" : {
19+
"message" : "Another test ..."
20+
}
21+
}
22+
]
23+
}

specification/_global/render_search_template/RenderSearchTemplateRequest.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,25 @@ import { Id } from '@_types/common'
2929
* @rest_spec_name render_search_template
3030
* @availability stack stability=stable
3131
* @availability serverless stability=stable visibility=public
32+
* @index_privileges read
3233
* @doc_tag search
34+
* @doc_id render-search-template-api
3335
*/
3436
export interface Request extends RequestBase {
3537
path_parts: {
3638
/**
37-
* ID of the search template to render.
39+
* The ID of the search template to render.
3840
* If no `source` is specified, this or the `id` request body parameter is required.
3941
*/
4042
id?: Id
4143
}
4244
body: {
45+
/**
46+
* The ID of the search template to render.
47+
* If no `source` is specified, this or the `<template-id>` request path parameter is required.
48+
* If you specify both this parameter and the `<template-id>` parameter, the API uses only `<template-id>`.
49+
*/
50+
id?: Id
4351
file?: string
4452
/**
4553
* Key-value pairs used to replace Mustache variables in the template.
@@ -49,7 +57,7 @@ export interface Request extends RequestBase {
4957
params?: Dictionary<string, UserDefinedValue>
5058
/**
5159
* An inline search template.
52-
* Supports the same parameters as the search API's request body.
60+
* It supports the same parameters as the search API's request body.
5361
* These parameters also support Mustache variables.
5462
* If no `id` or `<templated-id>` is specified, this parameter is required.
5563
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# summary:
2+
# method_request: POST _render/template
3+
description: Run `POST _render/template`
4+
# type: request
5+
value: |-
6+
{
7+
"id": "my-search-template",
8+
"params": {
9+
"query_string": "hello world",
10+
"from": 20,
11+
"size": 10
12+
}
13+
}

0 commit comments

Comments
 (0)