Skip to content

Commit 9fc1d74

Browse files
authored
Merge branch 'main' into add/knn.warmup
Signed-off-by: Sai Medhini Reddy Maryada <[email protected]>
2 parents acca36c + 875cad1 commit 9fc1d74

File tree

14 files changed

+440
-2
lines changed

14 files changed

+440
-2
lines changed

.github/workflows/coverage.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: API Coverage
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
JAVA_VERSION: 11
7+
OPENSEARCH_INITIAL_ADMIN_PASSWORD: BobgG7YrtsdKf9M
8+
9+
jobs:
10+
coverage:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@v2
17+
- name: Build and Run Docker Container
18+
run: |
19+
docker build coverage --tag opensearch-with-api-plugin
20+
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_INITIAL_ADMIN_PASSWORD" opensearch-with-api-plugin
21+
sleep 15
22+
- name: Display OpenSearch Info
23+
run: |
24+
curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/ | jq
25+
- name: Dump and Compare API
26+
run: |
27+
curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/_plugins/api | jq > OpenSearch.auto.openapi.json
28+
docker run --rm --mount type=bind,source=.,target=/specs openapitools/openapi-diff:latest /specs/OpenSearch.openapi.json /specs/OpenSearch.auto.openapi.json --json /specs/diff.json
29+
- name: Show Diff
30+
run: |
31+
echo "-------- Missing APIs"
32+
jq -r '.newEndpoints | group_by(.pathUrl)[] | "\(.[0].pathUrl): \([.[].method])"' diff.json
33+
echo "-------- Legacy APIs"
34+
jq -r '.missingEndpoints | group_by(.pathUrl)[] | "\(.[0].pathUrl): \([.[].method])"' diff.json
35+
- name: Gather Coverage
36+
id: coverage
37+
shell: bash
38+
run: |
39+
current=`jq -r '.paths | keys | length' OpenSearch.openapi.json`
40+
total=`jq -r '.paths | keys | length' OpenSearch.auto.openapi.json`
41+
percent=$((current * 100 / total))
42+
echo "API specs implemented for $current/$total ($percent%) APIs."

coverage/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ARG OPENSEARCH_VERSION=2.12.0
2+
FROM opensearchproject/opensearch:${OPENSEARCH_VERSION}
3+
ARG OPENSEARCH_VERSION
4+
RUN /usr/share/opensearch/bin/opensearch-plugin \
5+
install \
6+
--batch \
7+
https://github.com/dblock/opensearch-api/releases/download/v${OPENSEARCH_VERSION}/opensearch-api-${OPENSEARCH_VERSION}.0.zip

coverage/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### API Coverage
2+
3+
Uses the [opensearch-api plugin](https://github.com/dblock/opensearch-api), and [openapi-diff](https://github.com/OpenAPITools/openapi-diff) to show the difference between OpenSearch APIs, and the [OpenAPI spec checked into this repo](../OpenSearch.openapi.json).
4+
5+
API coverage is run on all pull requests via the [coverage workflow](../.github/workflows/coverage.yml).
6+
7+

model/common_strings.smithy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ string PathTaskId
247247
@documentation("The name of the template.")
248248
string PathTemplateName
249249

250+
@pattern("^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$")
251+
@documentation("The id of the model.")
252+
string PathModelId
253+
250254
@documentation("The analyzer to use for the query string.")
251255
string Analyzer
252256

@@ -281,6 +285,9 @@ string Lang
281285
@documentation("Comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names.")
282286
string NodeIds
283287

288+
@documentation("Preferred node to execute training.")
289+
string NodeId
290+
284291
@documentation("Comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids.")
285292
string NodeNames
286293

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// The OpenSearch Contributors require contributions made to
4+
// this file be licensed under the Apache-2.0 license or a
5+
// compatible open source license.
6+
7+
$version: "2"
8+
namespace OpenSearch
9+
10+
@externalDocumentation(
11+
"API Reference": "https://opensearch.org/docs/latest/search-plugins/knn/api/#delete-model"
12+
)
13+
14+
@xOperationGroup("knn.delete_model")
15+
@xVersionAdded("1.0")
16+
@suppress(["HttpMethodSemantics.UnexpectedPayload"])
17+
@suppress(["HttpUriConflict"])
18+
@http(method: "DELETE", uri: "/_plugins/_knn/models/{model_id}")
19+
@documentation("Used to delete a particular model in the cluster.")
20+
operation KNNDeleteModel {
21+
input: KNNDeleteModel_Input,
22+
output: KNNDeleteModel_Output
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// The OpenSearch Contributors require contributions made to
4+
// this file be licensed under the Apache-2.0 license or a
5+
// compatible open source license.
6+
7+
$version: "2"
8+
namespace OpenSearch
9+
10+
@input
11+
structure KNNDeleteModel_Input {
12+
@required
13+
@httpLabel
14+
model_id: PathModelId,
15+
}
16+
17+
// TODO: Fill in Output Structure
18+
structure KNNDeleteModel_Output {}

model/knn/get_model/operations.smithy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// The OpenSearch Contributors require contributions made to
4+
// this file be licensed under the Apache-2.0 license or a
5+
// compatible open source license.
6+
7+
$version: "2"
8+
namespace OpenSearch
9+
10+
@externalDocumentation(
11+
"API Reference": "https://opensearch.org/docs/latest/search-plugins/knn/api/#get-model"
12+
)
13+
14+
@xOperationGroup("knn.get_model")
15+
@xVersionAdded("1.0")
16+
@readonly
17+
@suppress(["HttpUriConflict"])
18+
@http(method: "GET", uri: "/_plugins/_knn/models/{model_id}")
19+
@documentation("Used to retrieve information about models present in the cluster.")
20+
operation KNNGetModel {
21+
input: KNNGetModel_Input,
22+
output: KNNGetModel_Output
23+
}

model/knn/get_model/structures.smithy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// The OpenSearch Contributors require contributions made to
4+
// this file be licensed under the Apache-2.0 license or a
5+
// compatible open source license.
6+
7+
$version: "2"
8+
namespace OpenSearch
9+
10+
@input
11+
structure KNNGetModel_Input {
12+
@required
13+
@httpLabel
14+
model_id: PathModelId,
15+
}
16+
17+
// TODO: Fill in Output Structure
18+
structure KNNGetModel_Output {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// The OpenSearch Contributors require contributions made to
4+
// this file be licensed under the Apache-2.0 license or a
5+
// compatible open source license.
6+
7+
$version: "2"
8+
namespace OpenSearch
9+
10+
@externalDocumentation(
11+
"API Reference": "https://opensearch.org/docs/latest/search-plugins/knn/api/#search-model"
12+
)
13+
14+
@xOperationGroup("knn.search_models")
15+
@xVersionAdded("1.0")
16+
@readonly
17+
@suppress(["HttpUriConflict"])
18+
@http(method: "GET", uri: "/_plugins/_knn/models/_search")
19+
@documentation("Use an OpenSearch query to search for models in the index.")
20+
operation KNNSearchModels_Get {
21+
input: KNNSearchModels_Get_Input,
22+
output: KNNSearchModels_Output
23+
}
24+
25+
@xOperationGroup("knn.search_models")
26+
@xVersionAdded("1.0")
27+
@suppress(["HttpUriConflict"])
28+
@http(method: "POST", uri: "/_plugins/_knn/models/_search")
29+
@documentation("Use an OpenSearch query to search for models in the index.")
30+
operation KNNSearchModels_Post {
31+
input: KNNSearchModels_Post_Input,
32+
output: KNNSearchModels_Output
33+
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
//
3+
// The OpenSearch Contributors require contributions made to
4+
// this file be licensed under the Apache-2.0 license or a
5+
// compatible open source license.
6+
7+
$version: "2"
8+
namespace OpenSearch
9+
10+
@mixin
11+
structure KNNSearchModels_QueryParams {
12+
@httpQuery("analyzer")
13+
analyzer: Analyzer,
14+
15+
@httpQuery("analyze_wildcard")
16+
@default(false)
17+
analyze_wildcard: AnalyzeWildcard,
18+
19+
@httpQuery("ccs_minimize_roundtrips")
20+
@default(true)
21+
ccs_minimize_roundtrips: CcsMinimizeRoundtrips,
22+
23+
@httpQuery("default_operator")
24+
@default("OR")
25+
default_operator: DefaultOperator,
26+
27+
@httpQuery("df")
28+
df: Df,
29+
30+
@httpQuery("explain")
31+
@documentation("Specify whether to return detailed information about score computation as part of a hit.")
32+
explain: Explain,
33+
34+
@httpQuery("stored_fields")
35+
stored_fields: StoredFields,
36+
37+
@httpQuery("docvalue_fields")
38+
docvalue_fields: DocvalueFields,
39+
40+
@httpQuery("from")
41+
@default(0)
42+
from: From,
43+
44+
@httpQuery("ignore_unavailable")
45+
ignore_unavailable: IgnoreUnavailable,
46+
47+
@httpQuery("ignore_throttled")
48+
ignore_throttled: IgnoreThrottled,
49+
50+
@httpQuery("allow_no_indices")
51+
allow_no_indices: AllowNoIndices,
52+
53+
@httpQuery("expand_wildcards")
54+
@default("open")
55+
expand_wildcards: ExpandWildcards,
56+
57+
@httpQuery("lenient")
58+
lenient: Lenient,
59+
60+
@httpQuery("preference")
61+
@default("random")
62+
preference: Preference,
63+
64+
@httpQuery("q")
65+
q: Q,
66+
67+
@httpQuery("routing")
68+
routing: Routings,
69+
70+
@httpQuery("scroll")
71+
scroll: Scroll,
72+
73+
@httpQuery("search_type")
74+
search_type: SearchType,
75+
76+
@httpQuery("size")
77+
@documentation("Number of hits to return.")
78+
@default(10)
79+
size: Size,
80+
81+
@httpQuery("sort")
82+
sort: Sort,
83+
84+
@httpQuery("_source")
85+
_source: Source,
86+
87+
@httpQuery("_source_excludes")
88+
_source_excludes: SourceExcludes,
89+
90+
@httpQuery("_source_includes")
91+
_source_includes: SourceIncludes,
92+
93+
@httpQuery("terminate_after")
94+
terminate_after: TerminateAfter,
95+
96+
@httpQuery("stats")
97+
stats: Stats,
98+
99+
@httpQuery("suggest_field")
100+
suggest_field: SuggestField,
101+
102+
@httpQuery("suggest_mode")
103+
@default("missing")
104+
suggest_mode: SuggestMode,
105+
106+
@httpQuery("suggest_size")
107+
suggest_size: SuggestSize,
108+
109+
@httpQuery("suggest_text")
110+
suggest_text: SuggestText,
111+
112+
@httpQuery("timeout")
113+
timeout: Timeout,
114+
115+
@httpQuery("track_scores")
116+
track_scores: TrackScores,
117+
118+
@httpQuery("track_total_hits")
119+
track_total_hits: TrackTotalHits,
120+
121+
@httpQuery("allow_partial_search_results")
122+
@default(true)
123+
allow_partial_search_results: AllowPartialSearchResults,
124+
125+
@httpQuery("typed_keys")
126+
typed_keys: TypedKeys,
127+
128+
@httpQuery("version")
129+
version: WithVersion,
130+
131+
@httpQuery("seq_no_primary_term")
132+
seq_no_primary_term: SeqNoPrimaryTerm,
133+
134+
@httpQuery("request_cache")
135+
request_cache: RequestCache,
136+
137+
@httpQuery("batched_reduce_size")
138+
@default(512)
139+
batched_reduce_size: BatchedReduceSize,
140+
141+
@httpQuery("max_concurrent_shard_requests")
142+
@documentation("The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests.")
143+
@default(5)
144+
max_concurrent_shard_requests: MaxConcurrentShardRequests,
145+
146+
@httpQuery("pre_filter_shard_size")
147+
pre_filter_shard_size: PreFilterShardSize,
148+
149+
@httpQuery("rest_total_hits_as_int")
150+
@default(false)
151+
rest_total_hits_as_int: RestTotalHitsAsInt,
152+
}
153+
154+
// TODO: Fill in Body Parameters
155+
structure KNNSearchModels_BodyParams {}
156+
157+
@input
158+
structure KNNSearchModels_Get_Input with [KNNSearchModels_QueryParams] {}
159+
160+
@input
161+
structure KNNSearchModels_Post_Input with [KNNSearchModels_QueryParams] {
162+
@httpPayload
163+
content: KNNSearchModels_BodyParams,
164+
}
165+
166+
// TODO: Fill in Output Structure
167+
structure KNNSearchModels_Output {}

0 commit comments

Comments
 (0)