Skip to content

Commit fa566ed

Browse files
authored
Add Query Rules API (#2207)
1 parent 66771b5 commit fa566ed

19 files changed

+1298
-8
lines changed

output/schema/schema.json

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

output/schema/validation-errors.json

Lines changed: 6 additions & 0 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: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"query_ruleset.delete": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-ruleset.html",
5+
"description": "Deletes a query ruleset."
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": ["application/json"]
11+
},
12+
"url": {
13+
"paths": [
14+
{
15+
"path": "/_query_rules/{ruleset_id}",
16+
"methods": ["DELETE"],
17+
"parts": {
18+
"ruleset_id": {
19+
"type": "string",
20+
"description": "The unique identifier of the query ruleset to delete"
21+
}
22+
}
23+
}
24+
]
25+
}
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"query_ruleset.get": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-ruleset.html",
5+
"description": "Returns the details about a query ruleset."
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": ["application/json"]
11+
},
12+
"url": {
13+
"paths": [
14+
{
15+
"path": "/_query_rules/{ruleset_id}",
16+
"methods": ["GET"],
17+
"parts": {
18+
"ruleset_id": {
19+
"type": "string",
20+
"description": "The unique identifier of the query ruleset"
21+
}
22+
}
23+
}
24+
]
25+
}
26+
}
27+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"query_ruleset.list": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html",
5+
"description": "Lists query rulesets."
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": ["application/json"]
11+
},
12+
"url": {
13+
"paths": [
14+
{
15+
"path": "/_query_rules",
16+
"methods": ["GET"]
17+
}
18+
]
19+
},
20+
"params": {
21+
"from": {
22+
"type": "int",
23+
"default": 0,
24+
"description": "Starting offset (default: 0)"
25+
},
26+
"size": {
27+
"type": "int",
28+
"default": 100,
29+
"description": "specifies a max number of results to get (default: 100)"
30+
}
31+
}
32+
}
33+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"query_ruleset.put": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-ruleset.html",
5+
"description": "Creates or updates a query ruleset."
6+
},
7+
"stability": "experimental",
8+
"visibility": "public",
9+
"headers": {
10+
"accept": ["application/json"],
11+
"content_type": ["application/json"]
12+
},
13+
"url": {
14+
"paths": [
15+
{
16+
"path": "/_query_rules/{ruleset_id}",
17+
"methods": ["PUT"],
18+
"parts": {
19+
"ruleset_id": {
20+
"type": "string",
21+
"description": "The unique identifier of the ruleset to be created or updated."
22+
}
23+
}
24+
}
25+
]
26+
},
27+
"body": {
28+
"description": "The query ruleset configuration, including `rules`",
29+
"required": true
30+
}
31+
}
32+
}

specification/_types/query_dsl/abstractions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import {
7575
PercolateQuery,
7676
PinnedQuery,
7777
RankFeatureQuery,
78+
RuleQuery,
7879
ScriptQuery,
7980
ScriptScoreQuery,
8081
ShapeQuery
@@ -188,6 +189,7 @@ export class QueryContainer {
188189
range?: SingleKeyDictionary<Field, RangeQuery>
189190
rank_feature?: RankFeatureQuery
190191
regexp?: SingleKeyDictionary<Field, RegexpQuery>
192+
rule_query?: RuleQuery
191193
script?: ScriptQuery
192194
script_score?: ScriptScoreQuery
193195
shape?: ShapeQuery

specification/_types/query_dsl/specialized.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,9 @@ export class ShapeFieldQuery {
201201
relation?: GeoShapeRelation
202202
shape?: GeoShape
203203
}
204+
205+
export class RuleQuery extends QueryBase {
206+
organic: QueryContainer
207+
ruleset_id: Id
208+
match_criteria: UserDefinedValue
209+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 { Id, IndexName, Name } from '@_types/common'
21+
import { EpochTime, UnitMillis } from '@_types/Time'
22+
import { InlineScript } from '@_types/Scripting'
23+
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
24+
import { PinnedDoc } from '../../_types/query_dsl/specialized'
25+
26+
export class QueryRuleset {
27+
/**
28+
* Query Ruleset unique identifier
29+
*/
30+
ruleset_id: Id
31+
/**
32+
* Rules associated with the query ruleset
33+
*/
34+
rules: QueryRule[]
35+
}
36+
37+
export class QueryRule {
38+
rule_id: Id
39+
type: QueryRuleType
40+
criteria: QueryRuleCriteria[]
41+
actions: QueryRuleActions
42+
}
43+
44+
export enum QueryRuleType {
45+
pinned
46+
}
47+
48+
export class QueryRuleCriteria {
49+
type: QueryRuleCriteriaType
50+
metadata: string
51+
values?: UserDefinedValue[]
52+
}
53+
54+
export enum QueryRuleCriteriaType {
55+
global,
56+
exact,
57+
exact_fuzzy,
58+
prefix,
59+
suffix,
60+
contains,
61+
lt,
62+
lte,
63+
gt,
64+
gte
65+
}
66+
67+
export class QueryRuleActions {
68+
ids?: Id[]
69+
docs?: PinnedDoc[]
70+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
import { RequestBase } from '@_types/Base'
20+
import { Id } from '@_types/common'
21+
22+
/**
23+
* Deletes a query ruleset.
24+
* @rest_spec_name query_ruleset.delete
25+
* @availability stack since=8.10.0 stability=experimental
26+
* @availability serverless stability=experimental visibility=public
27+
*/
28+
interface Request extends RequestBase {
29+
path_parts: {
30+
/**
31+
* The unique identifier of the query ruleset to delete
32+
*/
33+
ruleset_id: Id
34+
}
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 { AcknowledgedResponseBase } from '@_types/Base'
21+
22+
export class Response {
23+
body: AcknowledgedResponseBase
24+
}

0 commit comments

Comments
 (0)