From 1c4b9c6b5b74d7bb8767c591c1f78c9ae991546b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Mon, 27 Jun 2022 12:23:50 +0200 Subject: [PATCH 1/3] fix(specs): correct type for `renderingContent` and `consequenceParams` --- .redocly.yaml | 2 +- config/openapitools.json | 6 +- specs/common/schemas/IndexSettings.yml | 60 ++++++++++++++++++- specs/search/paths/rules/common/schemas.yml | 57 ++++++++++++++++-- tests/CTS/methods/requests/search/search.json | 34 ++++++++++- 5 files changed, 144 insertions(+), 15 deletions(-) diff --git a/.redocly.yaml b/.redocly.yaml index 5f4326c036..1472e32c56 100644 --- a/.redocly.yaml +++ b/.redocly.yaml @@ -1,4 +1,4 @@ -apiDefinitions: +apis: abtesting: specs/abtesting/spec.yml analytics: specs/analytics/spec.yml insights: specs/insights/spec.yml diff --git a/config/openapitools.json b/config/openapitools.json index 8a65d6ad5e..04dd052b83 100644 --- a/config/openapitools.json +++ b/config/openapitools.json @@ -4,21 +4,21 @@ "generators": { "javascript-search": { "output": "#{cwd}/clients/algoliasearch-client-javascript/packages/client-search", - "reservedWordsMappings": "queryParameters=queryParameters,requestOptions=requestOptions", + "reservedWordsMappings": "queryParameters=queryParameters,requestOptions=requestOptions,delete=delete", "additionalProperties": { "packageVersion": "0.6.1" } }, "javascript-lite": { "output": "#{cwd}/clients/algoliasearch-client-javascript/packages/algoliasearch/lite", - "reservedWordsMappings": "queryParameters=queryParameters,requestOptions=requestOptions", + "reservedWordsMappings": "queryParameters=queryParameters,requestOptions=requestOptions,delete=delete", "additionalProperties": { "packageVersion": "0.6.1" } }, "javascript-recommend": { "output": "#{cwd}/clients/algoliasearch-client-javascript/packages/recommend", - "reservedWordsMappings": "queryParameters=queryParameters", + "reservedWordsMappings": "queryParameters=queryParameters,delete=delete", "additionalProperties": { "packageVersion": "0.6.1" } diff --git a/specs/common/schemas/IndexSettings.yml b/specs/common/schemas/IndexSettings.yml index ae7fdfd7fa..8491f5a773 100644 --- a/specs/common/schemas/IndexSettings.yml +++ b/specs/common/schemas/IndexSettings.yml @@ -268,9 +268,7 @@ indexSettingsAsSearchParams: description: When attribute is ranked above proximity in your ranking formula, proximity is used to select which searchable attribute is matched in the attribute ranking stage. default: false renderingContent: - type: object - description: Content defining how the search interface should be rendered. Can be set via the settings for a default value and can be overridden via rules. - default: {} + $ref: '#/renderingContent' maxFacetHits: type: integer @@ -356,3 +354,59 @@ removeStopWords: type: string - type: boolean default: false + +renderingContent: + description: Content defining how the search interface should be rendered. Can be set via the settings for a default value and can be overridden via rules. + type: object + additionalProperties: false + properties: + facetOrdering: + $ref: '#/facetOrdering' + +facetOrdering: + description: Defining how facets should be ordered. + type: object + additionalProperties: false + properties: + facets: + $ref: '#/facets' + values: + $ref: '#/values' + +facets: + description: The ordering of facets (widgets). + type: object + additionalProperties: false + properties: + order: + $ref: '#/order' + +values: + description: The ordering of facet values, within an individual list. + type: object + additionalProperties: + $ref: '#/value' + +value: + type: object + additionalProperties: false + properties: + order: + $ref: '#/order' + sortRemainingBy: + $ref: '#/sortRemainingBy' + +order: + description: Pinned order of facet lists. + type: array + items: + type: string + +sortRemainingBy: + description: > + How to display the remaining items. + - `count`: facet count (descending). + - `alpha`: alphabetical (ascending). + - `hidden`: show only pinned values. + type: string + enum: [count, alpha, hidden] diff --git a/specs/search/paths/rules/common/schemas.yml b/specs/search/paths/rules/common/schemas.yml index 504d6d26aa..ae7d4cc4bf 100644 --- a/specs/search/paths/rules/common/schemas.yml +++ b/specs/search/paths/rules/common/schemas.yml @@ -114,18 +114,63 @@ params: additionalProperties: false properties: query: - type: string - description: Query string. + $ref: '#/query' automaticFacetFilters: - type: array description: Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. - items: - $ref: '#/automaticFacetFilter' + $ref: '#/automaticFacetFilters' automaticOptionalFacetFilters: - type: object description: Same syntax as automaticFacetFilters, but the engine treats the filters as optional. + $ref: '#/automaticFacetFilters' + renderingContent: + $ref: '../../../../common/schemas/IndexSettings.yml#/renderingContent' + +query: + description: When providing a string, it replaces the entire query string. When providing an object, it describes incremental edits to be made to the query string (but you can't do both). + oneOf: + - $ref: '#/consequenceQuery' + - type: string + +consequenceQuery: + type: object + additionalProperties: false + properties: + remove: + description: Words to remove. + type: array + items: + type: string + edits: + description: Edits to apply. + type: array + items: + $ref: '#/edit' + +edit: + type: object + additionalProperties: false + properties: + type: + $ref: '#/editType' + delete: + description: Text or patterns to remove from the query string. + type: string + insert: + description: Text that should be inserted in place of the removed text inside the query string. + type: string + +editType: + description: Type of edit. + type: string + enum: [remove, replace] + +automaticFacetFilters: + oneOf: + - type: array items: $ref: '#/automaticFacetFilter' + - type: array + items: + type: string automaticFacetFilter: type: object diff --git a/tests/CTS/methods/requests/search/search.json b/tests/CTS/methods/requests/search/search.json index d02b29c5c9..cc5af2e650 100644 --- a/tests/CTS/methods/requests/search/search.json +++ b/tests/CTS/methods/requests/search/search.json @@ -328,7 +328,22 @@ ], "attributeCriteriaComputedByMinProximity": true, "renderingContent": { - "string": "any" + "facetOrdering": { + "facets": { + "order": [ + "a", + "b" + ] + }, + "values": { + "a": { + "order": [ + "b" + ], + "sortRemainingBy": "count" + } + } + } }, "type": "default" } @@ -470,7 +485,22 @@ ], "attributeCriteriaComputedByMinProximity": true, "renderingContent": { - "string": "any" + "facetOrdering": { + "facets": { + "order": [ + "a", + "b" + ] + }, + "values": { + "a": { + "order": [ + "b" + ], + "sortRemainingBy": "count" + } + } + } }, "type": "default" } From 0d7bd697ee7347fde04c76229523d02ecddcab3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Mon, 27 Jun 2022 12:37:05 +0200 Subject: [PATCH 2/3] trigger CI --- .github/.cache_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.cache_version b/.github/.cache_version index 1750564f27..5a5831ab6b 100644 --- a/.github/.cache_version +++ b/.github/.cache_version @@ -1 +1 @@ -0.0.6 +0.0.7 From 0a393fb37882ac44b731e99c035a3e6cb3e3691c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Mon, 27 Jun 2022 15:21:21 +0200 Subject: [PATCH 3/3] review --- specs/search/paths/rules/common/schemas.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/specs/search/paths/rules/common/schemas.yml b/specs/search/paths/rules/common/schemas.yml index ae7d4cc4bf..de1ebb58b0 100644 --- a/specs/search/paths/rules/common/schemas.yml +++ b/specs/search/paths/rules/common/schemas.yml @@ -116,11 +116,9 @@ params: query: $ref: '#/query' automaticFacetFilters: - description: Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. $ref: '#/automaticFacetFilters' automaticOptionalFacetFilters: - description: Same syntax as automaticFacetFilters, but the engine treats the filters as optional. - $ref: '#/automaticFacetFilters' + $ref: '#/automaticOptionalFacetFilters' renderingContent: $ref: '../../../../common/schemas/IndexSettings.yml#/renderingContent' @@ -164,6 +162,7 @@ editType: enum: [remove, replace] automaticFacetFilters: + description: Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. oneOf: - type: array items: @@ -172,6 +171,10 @@ automaticFacetFilters: items: type: string +automaticOptionalFacetFilters: + description: Same syntax as automaticFacetFilters, but the engine treats the filters as optional. + $ref: '#/automaticFacetFilters' + automaticFacetFilter: type: object description: Automatic facet Filter.