Skip to content

Commit 9c1b59f

Browse files
lcawlgithub-actions[bot]
authored andcommitted
[DOCS] Add examples and descriptions for explain, termvector, search APIs (#3614)
(cherry picked from commit 52b4f94)
1 parent 54f7abd commit 9c1b59f

28 files changed

+840
-228
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 62 additions & 59 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: 120 additions & 66 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,11 +25,14 @@ 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
urls: [
@@ -40,67 +43,76 @@ export interface Request extends RequestBase {
4043
]
4144
path_parts: {
4245
/**
43-
* Defines the document ID.
46+
* The document identifier.
4447
*/
4548
id: Id
4649
/**
47-
* Index names used to limit the request.
50+
* Index names that are used to limit the request.
4851
* Only a single index name can be provided to this parameter.
4952
*/
5053
index: IndexName
5154
}
5255
query_parameters: {
5356
/**
54-
* Analyzer to use for the query string.
55-
* This parameter can only be used when the `q` query string parameter is specified.
57+
* The analyzer to use for the query string.
58+
* This parameter can be used only when the `q` query string parameter is specified.
5659
*/
5760
analyzer?: string
5861
/**
5962
* If `true`, wildcard and prefix queries are analyzed.
63+
* This parameter can be used only when the `q` query string parameter is specified.
6064
* @server_default false
6165
*/
6266
analyze_wildcard?: boolean
6367
/**
6468
* The default operator for query string query: `AND` or `OR`.
69+
* This parameter can be used only when the `q` query string parameter is specified.
6570
* @server_default OR
6671
*/
6772
default_operator?: Operator
6873
/**
69-
* Field to use as default where no field prefix is given in the query string.
74+
* The field to use as default where no field prefix is given in the query string.
75+
* This parameter can be used only when the `q` query string parameter is specified.
7076
*/
7177
df?: string
7278
/**
7379
* If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
80+
* This parameter can be used only when the `q` query string parameter is specified.
7481
* @server_default false
7582
*/
7683
lenient?: boolean
7784
/**
78-
* Specifies the node or shard the operation should be performed on.
79-
* Random by default.
85+
* The node or shard the operation should be performed on.
86+
* It is random by default.
8087
*/
8188
preference?: string
8289
/**
83-
* Custom value used to route operations to a specific shard.
90+
* A custom value used to route operations to a specific shard.
8491
*/
8592
routing?: Routing
8693
/**
87-
* True or false to return the `_source` field or not, or a list of fields to return.
94+
* `True` or `false` to return the `_source` field or not or a list of fields to return.
8895
*/
8996
_source?: SourceConfigParam
9097
/**
9198
* A comma-separated list of source fields to exclude from the response.
99+
* You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
100+
* If the `_source` parameter is `false`, this parameter is ignored.
92101
*/
93102
_source_excludes?: Fields
94103
/**
95104
* A comma-separated list of source fields to include in the response.
105+
* If this parameter is specified, only these source fields are returned.
106+
* You can exclude fields from this subset using the `_source_excludes` query parameter.
107+
* If the `_source` parameter is `false`, this parameter is ignored.
96108
*/
97109
_source_includes?: Fields
98110
/**
99111
* A comma-separated list of stored fields to return in the response.
100112
*/
101113
stored_fields?: Fields
102114
/**
103-
* Query in the Lucene query string syntax.
115+
* The query in the Lucene query string syntax.
104116
*/
105117
q?: string
106118
}
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,14 +31,17 @@ 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
urls: [
@@ -53,15 +56,15 @@ export interface Request extends RequestBase {
5356
]
5457
path_parts: {
5558
/**
56-
* Name of the index that contains the documents.
59+
* The name of the index that contains the documents.
5760
*/
5861
index?: IndexName
5962
}
6063
query_parameters: {
6164
ids?: Id[]
6265
/**
63-
* Comma-separated list or wildcard expressions of fields to include in the statistics.
64-
* Used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters.
66+
* A comma-separated list or wildcard expressions of fields to include in the statistics.
67+
* It is used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters.
6568
*/
6669
fields?: Fields
6770
/**
@@ -85,8 +88,8 @@ export interface Request extends RequestBase {
8588
*/
8689
positions?: boolean
8790
/**
88-
* Specifies the node or shard the operation should be performed on.
89-
* Random by default.
91+
* The node or shard the operation should be performed on.
92+
* It is random by default.
9093
*/
9194
preference?: string
9295
/**
@@ -96,7 +99,7 @@ export interface Request extends RequestBase {
9699
*/
97100
realtime?: boolean
98101
/**
99-
* Custom value used to route operations to a specific shard.
102+
* A custom value used to route operations to a specific shard.
100103
*/
101104
routing?: Routing
102105
/**
@@ -109,17 +112,17 @@ export interface Request extends RequestBase {
109112
*/
110113
version?: VersionNumber
111114
/**
112-
* Specific version type.
115+
* The version type.
113116
*/
114117
version_type?: VersionType
115118
}
116119
body: {
117120
/**
118-
* Array of existing or artificial documents.
121+
* An array of existing or artificial documents.
119122
*/
120123
docs?: Operation[]
121124
/**
122-
* Simplified syntax to specify documents by their ID if they're in the same index.
125+
* A simplified syntax to specify documents by their ID if they're in the same index.
123126
*/
124127
ids?: Id[]
125128
}
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,7 +29,9 @@ 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
urls: [
@@ -44,12 +46,18 @@ export interface Request extends RequestBase {
4446
]
4547
path_parts: {
4648
/**
47-
* ID of the search template to render.
49+
* The ID of the search template to render.
4850
* If no `source` is specified, this or the `id` request body parameter is required.
4951
*/
5052
id?: Id
5153
}
5254
body: {
55+
/**
56+
* The ID of the search template to render.
57+
* If no `source` is specified, this or the `<template-id>` request path parameter is required.
58+
* If you specify both this parameter and the `<template-id>` parameter, the API uses only `<template-id>`.
59+
*/
60+
id?: Id
5361
file?: string
5462
/**
5563
* Key-value pairs used to replace Mustache variables in the template.
@@ -59,7 +67,7 @@ export interface Request extends RequestBase {
5967
params?: Dictionary<string, UserDefinedValue>
6068
/**
6169
* An inline search template.
62-
* Supports the same parameters as the search API's request body.
70+
* It supports the same parameters as the search API's request body.
6371
* These parameters also support Mustache variables.
6472
* If no `id` or `<templated-id>` is specified, this parameter is required.
6573
*/

0 commit comments

Comments
 (0)