Skip to content

Commit a83a6ed

Browse files
lcawlszabosteve
andauthored
[DOCS] Add behavioral analytics and search application examples (#3392)
Co-authored-by: István Zoltán Szabó <[email protected]>
1 parent e153632 commit a83a6ed

14 files changed

+149
-11
lines changed

compiler/src/model/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ export function hoistRequestAnnotations (
668668
const privileges = [
669669
'all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr',
670670
'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines',
671-
'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml',
671+
'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application',
672672
'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile',
673673
'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure',
674674
'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client'

docs/overlays/elasticsearch-shared-overlays.yaml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,15 @@ actions:
13511351
examples:
13521352
indicesRolloverResponseExample1:
13531353
$ref: "../../specification/indices/rollover/indicesRolloverResponseExample1.yaml"
1354+
## Examples for behavioral analytics
1355+
- target: "$.components['responses']['search_application.get_behavioral_analytics#200']"
1356+
description: "Add example for get behavioral analytics collections response"
1357+
update:
1358+
content:
1359+
application/json:
1360+
examples:
1361+
getBehavioralAnalyticsCollectionsResponseExample1:
1362+
$ref: "../../specification/search_application/get_behavioral_analytics/BehavioralAnalyticsGetResponseExample1.yaml"
13541363
## Examples for licensing
13551364
- target: "$.paths['/_license']['get']"
13561365
description: "Add example for get license response"
@@ -1361,4 +1370,42 @@ actions:
13611370
application/json:
13621371
examples:
13631372
getLicenseResponseExample1:
1364-
$ref: "../../specification/license/get/GetLicenseResponseExample1.yaml"
1373+
$ref: "../../specification/license/get/GetLicenseResponseExample1.yaml"
1374+
## Examples for search applications
1375+
- target: "$.paths['/_application/search_application']['get']"
1376+
description: "Add examples for get search applications operation"
1377+
update:
1378+
responses:
1379+
200:
1380+
content:
1381+
application/json:
1382+
examples:
1383+
getSearchApplicationsResponseExample1:
1384+
$ref: "../../specification/search_application/list/SearchApplicationsListResponseExample1.yaml"
1385+
- target: "$.paths['/_application/search_application/{name}']['get']"
1386+
description: "Add examples for get search application details operation"
1387+
update:
1388+
responses:
1389+
200:
1390+
content:
1391+
application/json:
1392+
examples:
1393+
getSearchApplicationResponseExample1:
1394+
$ref: "../../specification/search_application/get/SearchApplicationGetResponseExample1.yaml"
1395+
- target: "$.paths['/_application/search_application/{name}']['put']"
1396+
description: "Add examples for create search application operation"
1397+
update:
1398+
requestBody:
1399+
content:
1400+
application/json:
1401+
examples:
1402+
putSearchApplicationRequestExample1:
1403+
$ref: "../../specification/search_application/put/SearchApplicationPutRequestExample1.yaml"
1404+
- target: "$.components['requestBodies']['search_application.search']"
1405+
description: "Add example for search application search request"
1406+
update:
1407+
content:
1408+
application/json:
1409+
examples:
1410+
searchApplicationSearchRequestExample1:
1411+
$ref: "../../specification/search_application/search/SearchApplicationsSearchRequestExample1.yaml"

output/openapi/elasticsearch-openapi.json

Lines changed: 2 additions & 1 deletion
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: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

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

specification/search_application/delete/SearchApplicationsDeleteRequest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { Name } from '@_types/common'
2525
* @rest_spec_name search_application.delete
2626
* @availability stack since=8.8.0 stability=beta
2727
* @availability serverless stability=beta visibility=public
28+
* @cluster_privileges manage_search_application
29+
* @index_privileges manage
2830
*/
2931
export interface Request extends RequestBase {
3032
path_parts: {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# summary: search-application/apis/get-search-application.asciidoc:95
2+
description: A sucessful response from `GET _application/search_application/my-app/`.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"name\": \"my-app\",\n \"indices\": [ \"index1\", \"index2\" ],\n \
7+
\ \"updated_at_millis\": 1682105622204,\n \"template\": {\n \"script\": {\n\
8+
\ \"source\": {\n \"query\": {\n \"query_string\": {\n \
9+
\ \"query\": \"{{query_string}}\",\n \"default_field\": \"{{default_field}}\"\
10+
\n }\n }\n },\n \"lang\": \"mustache\",\n \"options\"\
11+
: {\n \"content_type\": \"application/json;charset=utf-8\"\n },\n \
12+
\ \"params\": {\n \"query_string\": \"*\",\n \"default_field\"\
13+
: \"*\"\n }\n }\n }\n}"

specification/search_application/get/SearchApplicationsGetRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Name } from '@_types/common'
2424
* @rest_spec_name search_application.get
2525
* @availability stack since=8.8.0 stability=beta
2626
* @availability serverless stability=beta visibility=public
27+
* @cluster_privileges manage_search_application
2728
*/
2829
export interface Request extends RequestBase {
2930
path_parts: {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# summary: behavioral-analytics/apis/list-analytics-collection.asciidoc:112
2+
description: A successful response from `GET _application/analytics/my*`
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"my_analytics_collection\": {\n \"event_data_stream\": {\n \
7+
\ \"name\": \"behavioral_analytics-events-my_analytics_collection\"\n \
8+
\ }\n },\n \"my_analytics_collection2\": {\n \"event_data_stream\": {\n \
9+
\ \"name\": \"behavioral_analytics-events-my_analytics_collection2\"\n \
10+
\ }\n }\n}"

specification/search_application/list/SearchApplicationsListRequest.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import { RequestBase } from '@_types/Base'
2020
import { integer } from '@_types/Numeric'
2121

2222
/**
23-
* Returns the existing search applications.
23+
* Get search applications.
24+
* Get information about search applications.
2425
* @rest_spec_name search_application.list
2526
* @availability stack since=8.8.0 stability=beta
2627
* @availability serverless stability=beta visibility=public
28+
* @cluster_privileges manage_search_application
2729
*/
2830
export interface Request extends RequestBase {
2931
query_parameters: {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# summary: search-application/apis/list-search-applications.asciidoc:108
2+
description: A succesful response from `GET _application/search_application?from=0&size=3&q=app*` returns the first three search applications whose names start with `app`.
3+
# type: response
4+
# response_code: 200
5+
value:
6+
"{\n \"count\": 2,\n \"results\": [\n {\n \"name\": \"app-1\",\n\
7+
\ \"updated_at_millis\": 1690981129366\n },\n {\n \"name\": \"app-2\"\
8+
,\n \"updated_at_millis\": 1691501823939\n }\n ]\n}"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# summary: search-application/apis/put-search-application.asciidoc:148
2+
# method_request: PUT _application/search_application/my-app
3+
description: >
4+
Run `PUT _application/search_application/my-app` to create or update a search application called `my-app`. When the dictionary parameter is specified, the search application search API will perform the following parameter validation: it accepts only the `query_string` and `default_field` parameters; it verifies that `query_string` and `default_field` are both strings; it accepts `default_field` only if it takes the values title or description. If the parameters are not valid, the search application search API will return an error.
5+
# type: request
6+
value:
7+
"{\n \"indices\": [ \"index1\", \"index2\" ],\n \"template\": {\n \"script\"\
8+
: {\n \"source\": {\n \"query\": {\n \"query_string\": {\n\
9+
\ \"query\": \"{{query_string}}\",\n \"default_field\": \"\
10+
{{default_field}}\"\n }\n }\n },\n \"params\": {\n \
11+
\ \"query_string\": \"*\",\n \"default_field\": \"*\"\n }\n },\n\
12+
\ \"dictionary\": {\n \"properties\": {\n \"query_string\": {\n \
13+
\ \"type\": \"string\"\n },\n \"default_field\": {\n \
14+
\ \"type\": \"string\",\n \"enum\": [\n \"title\",\n \
15+
\ \"description\"\n ]\n },\n \"additionalProperties\"\
16+
: false\n },\n \"required\": [\n \"query_string\"\n ]\n \
17+
\ }\n }\n}"

specification/search_application/put/SearchApplicationsPutRequest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { SearchApplicationParameters } from '../_types/SearchApplicationParamete
2525
* @rest_spec_name search_application.put
2626
* @availability stack since=8.8.0 stability=beta
2727
* @availability serverless stability=beta visibility=public
28+
* @cluster_privileges manage_search_application
29+
* @index_privileges manage
2830
*/
2931
export interface Request extends RequestBase {
3032
path_parts: {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# summary: search-application/apis/search-application-search.asciidoc:125
2+
# method_request: POST _application/search_application/my-app/_search
3+
description: Use `POST _application/search_application/my-app/_search` to run a search against a search application called `my-app` that uses a search template.
4+
# type: request
5+
value:
6+
"{\n \"params\": {\n \"query_string\": \"my first query\",\n \"text_fields\"\
7+
: [\n {\"name\": \"title\", \"boost\": 5},\n {\"name\": \"description\"\
8+
, \"boost\": 1}\n ]\n }\n}"

0 commit comments

Comments
 (0)