From 72cafab0c6099f7316544427b03dfa1a03de72e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Mon, 7 Mar 2022 10:28:00 +0100 Subject: [PATCH] fix(ui): display issues and gql queries --- specs/bundled/personalization.yml | 4 +- specs/bundled/query-suggestions.yml | 10 +- specs/bundled/recommend.yml | 110 +++++++++++------ specs/bundled/search.yml | 114 ++++++++++++------ specs/common/schemas/SearchParams.yml | 46 ++++--- .../paths/personalizationStrategy.yml | 2 - specs/query-suggestions/paths/qsConfig.yml | 4 - specs/query-suggestions/paths/qsConfigs.yml | 2 - specs/search/common/schemas/Hit.yml | 61 +++++++--- specs/search/paths/vault/vaultSources.yml | 2 - templates/javascript/model.mustache | 10 +- 11 files changed, 228 insertions(+), 137 deletions(-) diff --git a/specs/bundled/personalization.yml b/specs/bundled/personalization.yml index 57913e9b42b..1b9dc4668df 100644 --- a/specs/bundled/personalization.yml +++ b/specs/bundled/personalization.yml @@ -394,8 +394,6 @@ paths: tags: - personalization get: - tags: - - personalization operationId: getPersonalizationStrategy description: >- The strategy contains information on the events and facets that impact @@ -416,3 +414,5 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - personalization diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index 4221d622e47..cf81b374b07 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -454,8 +454,6 @@ paths: tags: - query-suggestions get: - tags: - - query-suggestions operationId: getAllConfigs description: > Get all the configurations of Query Suggestions. @@ -480,6 +478,8 @@ paths: $ref: '#/components/responses/StatusUnprocessableEntity' '500': $ref: '#/components/responses/InternalError' + tags: + - query-suggestions /1/configs/{indexName}: put: operationId: updateConfig @@ -503,8 +503,6 @@ paths: tags: - query-suggestions delete: - tags: - - query-suggestions operationId: deleteConfig description: > Delete a configuration of a Query Suggestion's index. @@ -526,9 +524,9 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '500': $ref: '#/components/responses/InternalError' - get: tags: - query-suggestions + get: operationId: getConfig description: Get the configuration of a single Query Suggestions index. summary: Get the configuration of a single Query Suggestions index. @@ -551,6 +549,8 @@ paths: $ref: '#/components/responses/IndexNotFound' '500': $ref: '#/components/responses/InternalError' + tags: + - query-suggestions /1/configs/{indexName}/status: get: operationId: getConfigStatus diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 0a36dcfc5a0..cc178dea6cb 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -52,18 +52,34 @@ components: type: string example: products description: The Algolia index name. + searchFilters: + oneOf: + - title: searchFiltersString + type: string + - title: searchFiltersArray + type: array + items: + type: string + - title: searchFiltersNestedArray + type: array + items: + type: array + items: + type: string page: type: integer description: Specify the page to retrieve. default: 0 + aroundRadiusAll: + type: string + enum: + - all aroundRadius: description: Define the maximum radius for a geo search (in meters). oneOf: - type: integer minimum: 1 - - type: string - enum: - - all + - $ref: '#/components/schemas/aroundRadiusAll' baseSearchParams: type: object additionalProperties: false @@ -79,32 +95,20 @@ components: description: Filter the query with numeric, facet and/or tag filters. default: '' facetFilters: - type: array - items: - type: string description: Filter hits by facet value. - default: [] + $ref: '#/components/schemas/searchFilters' optionalFilters: - type: array - items: - type: string description: >- Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. - default: [] + $ref: '#/components/schemas/searchFilters' numericFilters: - type: array - items: - type: string description: Filter on numeric attributes. - default: [] + $ref: '#/components/schemas/searchFilters' tagFilters: - type: array - items: - type: string description: Filter hits by tags. - default: [] + $ref: '#/components/schemas/searchFilters' sumOrFiltersScores: type: boolean description: Determines how to calculate the total score for filtering. @@ -237,6 +241,11 @@ components: type: boolean description: Whether this search should use AI Re-Ranking. default: true + reRankingApplyFilter: + description: >- + When Dynamic Re-Ranking is enabled, only records that match these + filters will be impacted by Dynamic Re-Ranking. + $ref: '#/components/schemas/searchFilters' query: type: string description: The text to search in the index. @@ -813,6 +822,34 @@ components: - none - partial - full + matchedGeoLocation: + type: object + properties: + lat: + type: number + format: double + description: Latitude of the matched location. + lng: + type: number + format: double + description: Longitude of the matched location. + distance: + type: integer + description: >- + Distance between the matched location and the search location (in + meters). + personalization: + type: object + properties: + filtersScore: + type: integer + description: The score of the filters. + rankingScore: + type: integer + description: The score of the ranking. + score: + type: integer + description: The score of the event. rankingInfo: type: object additionalProperties: false @@ -835,24 +872,9 @@ components: type: integer description: Precision used when computing the geo distance, in meters. matchedGeoLocation: - type: object - additionalProperties: - type: object - additionalProperties: false - properties: - lat: - type: number - format: double - description: Latitude of the matched location. - lng: - type: number - format: double - description: Longitude of the matched location. - distance: - type: integer - description: >- - Distance between the matched location and the search location - (in meters). + $ref: '#/components/schemas/matchedGeoLocation' + personalization: + $ref: '#/components/schemas/personalization' nbExactWords: type: integer description: Number of exactly matched words. @@ -870,9 +892,21 @@ components: userScore: type: integer description: Custom ranking for the object, expressed as a single integer value. - word: + words: type: integer description: Number of matched words, including prefixes and typos. + promotedByReRanking: + type: boolean + description: Wether the record are promoted by the re-ranking strategy. + required: + - promoted + - nbTypos + - firstMatchedWord + - geoDistance + - nbExactWords + - words + - filters + - userScore _distinctSeqID: type: integer recommendHit: diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 50a87ae95af..af8f21d90ff 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -164,18 +164,34 @@ components: properties: params: $ref: '#/components/schemas/paramsAsString' + searchFilters: + oneOf: + - title: searchFiltersString + type: string + - title: searchFiltersArray + type: array + items: + type: string + - title: searchFiltersNestedArray + type: array + items: + type: array + items: + type: string page: type: integer description: Specify the page to retrieve. default: 0 + aroundRadiusAll: + type: string + enum: + - all aroundRadius: description: Define the maximum radius for a geo search (in meters). oneOf: - type: integer minimum: 1 - - type: string - enum: - - all + - $ref: '#/components/schemas/aroundRadiusAll' baseSearchParams: type: object additionalProperties: false @@ -191,32 +207,20 @@ components: description: Filter the query with numeric, facet and/or tag filters. default: '' facetFilters: - type: array - items: - type: string description: Filter hits by facet value. - default: [] + $ref: '#/components/schemas/searchFilters' optionalFilters: - type: array - items: - type: string description: >- Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. - default: [] + $ref: '#/components/schemas/searchFilters' numericFilters: - type: array - items: - type: string description: Filter on numeric attributes. - default: [] + $ref: '#/components/schemas/searchFilters' tagFilters: - type: array - items: - type: string description: Filter hits by tags. - default: [] + $ref: '#/components/schemas/searchFilters' sumOrFiltersScores: type: boolean description: Determines how to calculate the total score for filtering. @@ -349,6 +353,11 @@ components: type: boolean description: Whether this search should use AI Re-Ranking. default: true + reRankingApplyFilter: + description: >- + When Dynamic Re-Ranking is enabled, only records that match these + filters will be impacted by Dynamic Re-Ranking. + $ref: '#/components/schemas/searchFilters' query: type: string description: The text to search in the index. @@ -864,6 +873,34 @@ components: - none - partial - full + matchedGeoLocation: + type: object + properties: + lat: + type: number + format: double + description: Latitude of the matched location. + lng: + type: number + format: double + description: Longitude of the matched location. + distance: + type: integer + description: >- + Distance between the matched location and the search location (in + meters). + personalization: + type: object + properties: + filtersScore: + type: integer + description: The score of the filters. + rankingScore: + type: integer + description: The score of the ranking. + score: + type: integer + description: The score of the event. rankingInfo: type: object additionalProperties: false @@ -886,24 +923,9 @@ components: type: integer description: Precision used when computing the geo distance, in meters. matchedGeoLocation: - type: object - additionalProperties: - type: object - additionalProperties: false - properties: - lat: - type: number - format: double - description: Latitude of the matched location. - lng: - type: number - format: double - description: Longitude of the matched location. - distance: - type: integer - description: >- - Distance between the matched location and the search location - (in meters). + $ref: '#/components/schemas/matchedGeoLocation' + personalization: + $ref: '#/components/schemas/personalization' nbExactWords: type: integer description: Number of exactly matched words. @@ -921,9 +943,21 @@ components: userScore: type: integer description: Custom ranking for the object, expressed as a single integer value. - word: + words: type: integer description: Number of matched words, including prefixes and typos. + promotedByReRanking: + type: boolean + description: Wether the record are promoted by the re-ranking strategy. + required: + - promoted + - nbTypos + - firstMatchedWord + - geoDistance + - nbExactWords + - words + - filters + - userScore _distinctSeqID: type: integer hit: @@ -3895,8 +3929,6 @@ paths: tags: - search put: - tags: - - search operationId: replaceSources description: Replace all allowed sources. summary: Replace all allowed sources. @@ -3929,6 +3961,8 @@ paths: $ref: '#/components/responses/MethodNotAllowed' '404': $ref: '#/components/responses/IndexNotFound' + tags: + - search /1/security/sources/append: post: operationId: appendSource diff --git a/specs/common/schemas/SearchParams.yml b/specs/common/schemas/SearchParams.yml index 36adff4d767..a2296f10fd5 100644 --- a/specs/common/schemas/SearchParams.yml +++ b/specs/common/schemas/SearchParams.yml @@ -30,31 +30,18 @@ baseSearchParams: type: string description: Filter the query with numeric, facet and/or tag filters. default: '' - # There could be a pattern for this one (complicated one) facetFilters: - type: array - items: - type: string description: Filter hits by facet value. - default: [] + $ref: '#/searchFilters' optionalFilters: - type: array - items: - type: string description: Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter. - default: [] + $ref: '#/searchFilters' numericFilters: - type: array - items: - type: string description: Filter on numeric attributes. - default: [] + $ref: '#/searchFilters' tagFilters: - type: array - items: - type: string description: Filter hits by tags. - default: [] + $ref: '#/searchFilters' sumOrFiltersScores: type: boolean description: Determines how to calculate the total score for filtering. @@ -164,6 +151,9 @@ baseSearchParams: type: boolean description: Whether this search should use AI Re-Ranking. default: true + reRankingApplyFilter: + description: When Dynamic Re-Ranking is enabled, only records that match these filters will be impacted by Dynamic Re-Ranking. + $ref: '#/searchFilters' searchParamsString: type: object @@ -197,5 +187,23 @@ aroundRadius: oneOf: - type: integer minimum: 1 - - type: string - enum: [all] + - $ref: '#/aroundRadiusAll' + +aroundRadiusAll: + type: string + enum: [all] + +searchFilters: + oneOf: + - title: searchFiltersString + type: string + - title: searchFiltersArray + type: array + items: + type: string + - title: searchFiltersNestedArray + type: array + items: + type: array + items: + type: string diff --git a/specs/personalization/paths/personalizationStrategy.yml b/specs/personalization/paths/personalizationStrategy.yml index 63ec4861988..f173f423ac8 100644 --- a/specs/personalization/paths/personalizationStrategy.yml +++ b/specs/personalization/paths/personalizationStrategy.yml @@ -32,8 +32,6 @@ post: '404': $ref: ../../common/responses/IndexNotFound.yml get: - tags: - - personalization operationId: getPersonalizationStrategy description: The strategy contains information on the events and facets that impact user profiles and personalized search results. summary: Get the current personalization strategy. diff --git a/specs/query-suggestions/paths/qsConfig.yml b/specs/query-suggestions/paths/qsConfig.yml index f4f2fae7747..45ca1ebfabf 100644 --- a/specs/query-suggestions/paths/qsConfig.yml +++ b/specs/query-suggestions/paths/qsConfig.yml @@ -19,8 +19,6 @@ put: $ref: ../../common/responses/InternalError.yml delete: - tags: - - query-suggestions operationId: deleteConfig description: > Delete a configuration of a Query Suggestion's index. @@ -42,8 +40,6 @@ delete: $ref: ../../common/responses/InternalError.yml get: - tags: - - query-suggestions operationId: getConfig description: Get the configuration of a single Query Suggestions index. summary: Get the configuration of a single Query Suggestions index. diff --git a/specs/query-suggestions/paths/qsConfigs.yml b/specs/query-suggestions/paths/qsConfigs.yml index fd71ca3d096..d0a2282e872 100644 --- a/specs/query-suggestions/paths/qsConfigs.yml +++ b/specs/query-suggestions/paths/qsConfigs.yml @@ -23,8 +23,6 @@ post: $ref: ../../common/responses/InternalError.yml get: - tags: - - query-suggestions operationId: getAllConfigs description: > Get all the configurations of Query Suggestions. diff --git a/specs/search/common/schemas/Hit.yml b/specs/search/common/schemas/Hit.yml index 819041769a3..8850e6dfbad 100644 --- a/specs/search/common/schemas/Hit.yml +++ b/specs/search/common/schemas/Hit.yml @@ -68,22 +68,9 @@ rankingInfo: type: integer description: Precision used when computing the geo distance, in meters. matchedGeoLocation: - type: object - additionalProperties: - type: object - additionalProperties: false - properties: - lat: - type: number - format: double - description: Latitude of the matched location. - lng: - type: number - format: double - description: Longitude of the matched location. - distance: - type: integer - description: Distance between the matched location and the search location (in meters). + $ref: '#/matchedGeoLocation' + personalization: + $ref: '#/personalization' nbExactWords: type: integer description: Number of exactly matched words. @@ -99,11 +86,51 @@ rankingInfo: userScore: type: integer description: Custom ranking for the object, expressed as a single integer value. - word: + words: type: integer description: Number of matched words, including prefixes and typos. + promotedByReRanking: + type: boolean + description: Wether the record are promoted by the re-ranking strategy. + required: + - promoted + - nbTypos + - firstMatchedWord + - geoDistance + - nbExactWords + - words + - filters + - userScore highlightedValue: type: string description: Markup text with occurrences highlighted. example: George Clooney + +matchedGeoLocation: + type: object + properties: + lat: + type: number + format: double + description: Latitude of the matched location. + lng: + type: number + format: double + description: Longitude of the matched location. + distance: + type: integer + description: Distance between the matched location and the search location (in meters). + +personalization: + type: object + properties: + filtersScore: + type: integer + description: The score of the filters. + rankingScore: + type: integer + description: The score of the ranking. + score: + type: integer + description: The score of the event. diff --git a/specs/search/paths/vault/vaultSources.yml b/specs/search/paths/vault/vaultSources.yml index 2dba28ad34d..50f7e5abf39 100644 --- a/specs/search/paths/vault/vaultSources.yml +++ b/specs/search/paths/vault/vaultSources.yml @@ -19,8 +19,6 @@ get: $ref: ../../../common/responses/IndexNotFound.yml put: - tags: - - search operationId: replaceSources description: Replace all allowed sources. summary: Replace all allowed sources. diff --git a/templates/javascript/model.mustache b/templates/javascript/model.mustache index 6abed907916..5d31bae2f73 100644 --- a/templates/javascript/model.mustache +++ b/templates/javascript/model.mustache @@ -6,10 +6,10 @@ import { {{classname}} } from '{{filename}}'; {{! We handle types that depend on other interfaces }} {{#interfaces.size}} -export type {{classname}} = {{#oneOf}}{{.}} {{^-last}}|{{/-last}} {{/oneOf}}{{#allOf}}{{.}} {{^-last}}&{{/-last}} {{/allOf}}; +export type {{classname}} = {{#oneOf}}{{{.}}} {{^-last}}|{{/-last}} {{/oneOf}}{{#allOf}}{{{.}}} {{^-last}}&{{/-last}} {{/allOf}}; {{/interfaces.size}} -{{^interfaces}} +{{^interfaces.size}} {{#description}} /** * {{{description}}} @@ -30,6 +30,7 @@ export type {{classname}} = { {{/vars}} } +{{/isEnum}} {{#hasEnums}} {{#vars}} {{#isEnum}} @@ -38,13 +39,10 @@ export type {{classname}}{{nameInCamelCase}} = {{#allowableValues}}{{#enumVars}} {{/isEnum}} {{/vars}} {{/hasEnums}} -{{/isEnum}} - {{#isEnum}} export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}|{{/-last}}{{/enumVars}}{{/allowableValues}} {{/isEnum}} - -{{/interfaces}} +{{/interfaces.size}} {{/model}} {{/models}}