Skip to content

Add Query Rules API #2207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
750 changes: 742 additions & 8 deletions output/schema/schema.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions output/schema/validation-errors.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions specification/_json_spec/query_ruleset.delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"query_ruleset.delete": {
"documentation": {
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-query-ruleset.html",
"description": "Deletes a query ruleset."
},
"stability": "experimental",
"visibility": "public",
"headers": {
"accept": ["application/json"]
},
"url": {
"paths": [
{
"path": "/_query_rules/{ruleset_id}",
"methods": ["DELETE"],
"parts": {
"ruleset_id": {
"type": "string",
"description": "The unique identifier of the query ruleset to delete"
}
}
}
]
}
}
}
27 changes: 27 additions & 0 deletions specification/_json_spec/query_ruleset.get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"query_ruleset.get": {
"documentation": {
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/get-query-ruleset.html",
"description": "Returns the details about a query ruleset."
},
"stability": "experimental",
"visibility": "public",
"headers": {
"accept": ["application/json"]
},
"url": {
"paths": [
{
"path": "/_query_rules/{ruleset_id}",
"methods": ["GET"],
"parts": {
"ruleset_id": {
"type": "string",
"description": "The unique identifier of the query ruleset"
}
}
}
]
}
}
}
33 changes: 33 additions & 0 deletions specification/_json_spec/query_ruleset.list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"query_ruleset.list": {
"documentation": {
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/list-query-rulesets.html",
"description": "Lists query rulesets."
},
"stability": "experimental",
"visibility": "public",
"headers": {
"accept": ["application/json"]
},
"url": {
"paths": [
{
"path": "/_query_rules",
"methods": ["GET"]
}
]
},
"params": {
"from": {
"type": "int",
"default": 0,
"description": "Starting offset (default: 0)"
},
"size": {
"type": "int",
"default": 100,
"description": "specifies a max number of results to get (default: 100)"
}
}
}
}
32 changes: 32 additions & 0 deletions specification/_json_spec/query_ruleset.put.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"query_ruleset.put": {
"documentation": {
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/put-query-ruleset.html",
"description": "Creates or updates a query ruleset."
},
"stability": "experimental",
"visibility": "public",
"headers": {
"accept": ["application/json"],
"content_type": ["application/json"]
},
"url": {
"paths": [
{
"path": "/_query_rules/{ruleset_id}",
"methods": ["PUT"],
"parts": {
"ruleset_id": {
"type": "string",
"description": "The unique identifier of the ruleset to be created or updated."
}
}
}
]
},
"body": {
"description": "The query ruleset configuration, including `rules`",
"required": true
}
}
}
2 changes: 2 additions & 0 deletions specification/_types/query_dsl/abstractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
PercolateQuery,
PinnedQuery,
RankFeatureQuery,
RuleQuery,
ScriptQuery,
ScriptScoreQuery,
ShapeQuery
Expand Down Expand Up @@ -188,6 +189,7 @@ export class QueryContainer {
range?: SingleKeyDictionary<Field, RangeQuery>
rank_feature?: RankFeatureQuery
regexp?: SingleKeyDictionary<Field, RegexpQuery>
rule_query?: RuleQuery
script?: ScriptQuery
script_score?: ScriptScoreQuery
shape?: ShapeQuery
Expand Down
6 changes: 6 additions & 0 deletions specification/_types/query_dsl/specialized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,9 @@ export class ShapeFieldQuery {
relation?: GeoShapeRelation
shape?: GeoShape
}

export class RuleQuery extends QueryBase {
organic: QueryContainer
ruleset_id: Id
match_criteria: UserDefinedValue
}
70 changes: 70 additions & 0 deletions specification/query_ruleset/_types/QueryRuleset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Id, IndexName, Name } from '@_types/common'
import { EpochTime, UnitMillis } from '@_types/Time'
import { InlineScript } from '@_types/Scripting'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
import { PinnedDoc } from '../../_types/query_dsl/specialized'

export class QueryRuleset {
/**
* Query Ruleset unique identifier
*/
ruleset_id: Id
/**
* Rules associated with the query ruleset
*/
rules: QueryRule[]
}

export class QueryRule {
rule_id: Id
type: QueryRuleType
criteria: QueryRuleCriteria[]
actions: QueryRuleActions
}

export enum QueryRuleType {
pinned
}

export class QueryRuleCriteria {
type: QueryRuleCriteriaType
metadata: string
values?: UserDefinedValue[]
}

export enum QueryRuleCriteriaType {
global,
exact,
exact_fuzzy,
prefix,
suffix,
contains,
lt,
lte,
gt,
gte
}

export class QueryRuleActions {
ids?: Id[]
docs?: PinnedDoc[]
}
35 changes: 35 additions & 0 deletions specification/query_ruleset/delete/QueryRulesetDeleteRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { RequestBase } from '@_types/Base'
import { Id } from '@_types/common'

/**
* Deletes a query ruleset.
* @rest_spec_name query_ruleset.delete
* @availability stack since=8.10.0 stability=experimental
* @availability serverless stability=experimental visibility=public
*/
interface Request extends RequestBase {
path_parts: {
/**
* The unique identifier of the query ruleset to delete
*/
ruleset_id: Id
}
}
24 changes: 24 additions & 0 deletions specification/query_ruleset/delete/QueryRulesetDeleteResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { AcknowledgedResponseBase } from '@_types/Base'

export class Response {
body: AcknowledgedResponseBase
}
Loading