Skip to content

Commit 003b872

Browse files
authored
Adding specification for the get random sample and get random sample stats APIs (#5528)
1 parent 75ab394 commit 003b872

File tree

14 files changed

+678
-12
lines changed

14 files changed

+678
-12
lines changed

output/schema/schema.json

Lines changed: 390 additions & 10 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: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"@stoplight/spectral-cli": "^6.14.2"
88
},
99
"version": "overlay"
10-
}
10+
}

specification/_doc_ids/table.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ edit-query-rule-from-ui,https://www.elastic.co/docs/solutions/search/query-rules
613613
delete-query-rule-from-ui,https://www.elastic.co/docs/solutions/search/query-rules-ui#delete-a-rule,,Delete a rule from the Query Rules UI
614614
list-query-rules-in-ui,https://www.elastic.co/docs/solutions/search/query-rules-ui#accessing-the-query-rules-ui,,See rules and rulesets in Query Rules UI
615615
delete-query-ruleset-from-ui,https://www.elastic.co/docs/solutions/search/query-rules-ui#delete-a-ruleset,,Delete a ruleset from the Query Rules UI
616+
random_sample,https://www.elastic.co/docs/api/doc/elasticsearch/group/ingest-random-sampling,,
616617
realtime,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/docs-get.html,
617618
redact-processor,https://www.elastic.co/docs/reference/enrich-processor/redact-processor,,
618619
regexp-syntax,https://www.elastic.co/docs/reference/query-languages/query-dsl/regexp-syntax,,

specification/_json_spec/indices.get_sample.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"description": "Get random sample of ingested data"
66
},
77
"stability": "experimental",
8-
"visibility": "public",
8+
"visibility": "feature_flag",
9+
"feature_flag": "random_sampling",
910
"headers": {
1011
"accept": ["application/json"]
1112
},
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { IndexName } from '@_types/common'
22+
23+
/**
24+
* Request for a random sample of raw documents ingested into the given index or data stream.
25+
*
26+
* @rest_spec_name indices.get_sample
27+
* @availability stack visibility=feature_flag feature_flag=random_sampling since=9.3.0 stability=experimental
28+
* @doc_id random_sample
29+
* @doc_tag random_sample
30+
*/
31+
export interface Request extends RequestBase {
32+
urls: [
33+
{
34+
path: '/{index}/_sample'
35+
methods: ['GET']
36+
}
37+
]
38+
path_parts: {
39+
/**
40+
* Single index or data stream name. Wildcards are not supported.
41+
*/
42+
index: IndexName
43+
}
44+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RawDocument } from './_types/RawDocument'
21+
22+
/**
23+
* Response type for the get_random_samples API.
24+
* It reuses the standard SearchResponse structure.
25+
*/
26+
export class Response {
27+
body: { sample: RawDocument[] }
28+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { PropertyName } from '@_types/common'
21+
import { Property } from '@_types/mapping/Property'
22+
import { Dictionary } from '@spec_utils/Dictionary'
23+
24+
export class RawDocument {
25+
/**
26+
* Name of the index for this raw document.
27+
*/
28+
index: string
29+
/**
30+
* The original raw source.
31+
*/
32+
source: Dictionary<PropertyName, Property>
33+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# summary: ''
2+
description: A successful response for retrieving the random sample for an index or data stream.
3+
# type: response
4+
# response_code: 200
5+
value: |-
6+
{
7+
"sample": [
8+
{
9+
"index": "logs",
10+
"source": {
11+
"@timestamp": "2099-11-15T13:12:00",
12+
"message": "Node 0 message",
13+
"user": {
14+
"id": "kimchy"
15+
},
16+
"network": {
17+
"name": "Guest"
18+
}
19+
}
20+
},
21+
{
22+
"index": "logs",
23+
"source": {
24+
"@timestamp": "2079-11-15T13:12:00",
25+
"message": "Node 1 message",
26+
"user": {
27+
"id": "kimchy"
28+
},
29+
"network": {
30+
"name": "Guest"
31+
}
32+
}
33+
}
34+
]
35+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
method_request: GET /my-index-000001/_sample

0 commit comments

Comments
 (0)