From bbcaf1d5da1e75c8358669ef1da3facefcc06b29 Mon Sep 17 00:00:00 2001 From: Chenyang Ji Date: Thu, 24 Oct 2024 10:37:09 -0700 Subject: [PATCH 1/2] allow additional properties for source field Signed-off-by: Chenyang Ji --- spec/schemas/insights._common.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/schemas/insights._common.yaml b/spec/schemas/insights._common.yaml index b4a70036..e4b8f538 100644 --- a/spec/schemas/insights._common.yaml +++ b/spec/schemas/insights._common.yaml @@ -137,7 +137,8 @@ components: NOTE: This is a debugging tool and adds significant overhead to search execution. type: boolean query: - $ref: '_common.query_dsl.yaml#/components/schemas/QueryContainer' + description: The query definition using the Query DSL. + type: object script_fields: description: Retrieve a script evaluation (based on different fields) for each hit. type: object @@ -205,6 +206,7 @@ components: type: array items: type: string + additionalProperties: true Measurement: type: object properties: From cefc17c428dddb1b0f32df11ee90cd6258406b98 Mon Sep 17 00:00:00 2001 From: Chenyang Ji Date: Thu, 24 Oct 2024 12:02:24 -0700 Subject: [PATCH 2/2] add adjust_pure_negative api spec Signed-off-by: Chenyang Ji --- CHANGELOG.md | 1 + spec/schemas/_common.query_dsl.yaml | 7 +++++++ spec/schemas/insights._common.yaml | 4 +--- .../query_insights/insights/top_queries.yaml | 13 +++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f291cd4b..fcb22f02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `config_id` and `config_id_list` to `/_plugins/_notifications/configs` query parameters ([#594](https://github.com/opensearch-project/opensearch-api-specification/pull/594)) - Added a release workflow triggered on a tag ([#635](https://github.com/opensearch-project/opensearch-api-specification/pull/635)) - Added API spec for query insights plugin ([#625](https://github.com/opensearch-project/opensearch-api-specification/pull/625)) +- Added API spec for `adjust_pure_negative` for bool queries ([#641](https://github.com/opensearch-project/opensearch-api-specification/pull/641)) ### Changed diff --git a/spec/schemas/_common.query_dsl.yaml b/spec/schemas/_common.query_dsl.yaml index 070d84ce..b8e43a86 100644 --- a/spec/schemas/_common.query_dsl.yaml +++ b/spec/schemas/_common.query_dsl.yaml @@ -270,6 +270,13 @@ components: - type: array items: $ref: '#/components/schemas/QueryContainer' + adjust_pure_negative: + description: |- + Ensures correct behavior when a query contains only must_not clauses. + By default set to true, OpenSearch adds a match-all clause to ensure results are returned from Lucene, with the must_not conditions applied as filters. + If set to false, the query may return no results, as Lucene typically requires at least one positive condition. + type: boolean + default: true QueryBase: type: object properties: diff --git a/spec/schemas/insights._common.yaml b/spec/schemas/insights._common.yaml index e4b8f538..b4a70036 100644 --- a/spec/schemas/insights._common.yaml +++ b/spec/schemas/insights._common.yaml @@ -137,8 +137,7 @@ components: NOTE: This is a debugging tool and adds significant overhead to search execution. type: boolean query: - description: The query definition using the Query DSL. - type: object + $ref: '_common.query_dsl.yaml#/components/schemas/QueryContainer' script_fields: description: Retrieve a script evaluation (based on different fields) for each hit. type: object @@ -206,7 +205,6 @@ components: type: array items: type: string - additionalProperties: true Measurement: type: object properties: diff --git a/tests/plugins/query_insights/insights/top_queries.yaml b/tests/plugins/query_insights/insights/top_queries.yaml index d1982891..d9a4c156 100644 --- a/tests/plugins/query_insights/insights/top_queries.yaml +++ b/tests/plugins/query_insights/insights/top_queries.yaml @@ -41,6 +41,19 @@ prologues: terms: field: director.raw + - path: /{index}/_search + parameters: + index: movies + method: GET + request: + payload: + query: + bool: + adjust_pure_negative: true + must: + match: + title: Drive + chapters: - synopsis: Retrieve default top queries. path: /_insights/top_queries