From c742cf3a52d750634cddd23a482e1e50710323ff Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 3 Dec 2021 16:20:05 +0100 Subject: [PATCH 1/7] feat: Added 6 synonyms endpoints for the search client --- .../model/clearAllSynonymsResponse.ts | 10 + .../model/deleteSynonymResponse.ts | 10 + .../client-search/model/models.ts | 7 + .../model/saveSynonymResponse.ts | 14 + .../model/saveSynonymsResponse.ts | 10 + .../model/searchSynonymsResponse.ts | 12 + .../client-search/model/synonymObject.ts | 36 ++ .../client-search/model/synonymType.ts | 10 + .../client-search/src/searchApi.ts | 312 +++++++++++++++++- specs/common/parameters.yml | 22 +- specs/search/paths/synonyms/batchSynonyms.yml | 37 +++ .../paths/synonyms/clearAllSynonyms.yml | 30 ++ specs/search/paths/synonyms/parameters.yml | 28 ++ specs/search/paths/synonyms/schemas.yml | 69 ++++ .../search/paths/synonyms/searchSynonyms.yml | 26 ++ specs/search/paths/synonyms/synonym.yml | 95 ++++++ specs/search/spec.yml | 16 +- 17 files changed, 732 insertions(+), 12 deletions(-) create mode 100644 clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/synonymType.ts create mode 100644 specs/search/paths/synonyms/parameters.yml create mode 100644 specs/search/paths/synonyms/schemas.yml diff --git a/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts new file mode 100644 index 00000000000..18df9a1f9c5 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts @@ -0,0 +1,10 @@ +export type ClearAllSynonymsResponse = { + /** + * TaskID of the indexing task to wait for. + */ + taskID?: number; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt?: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts new file mode 100644 index 00000000000..a0e2a469232 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts @@ -0,0 +1,10 @@ +export type DeleteSynonymResponse = { + /** + * TaskID of the indexing task to wait for. + */ + taskID?: number; + /** + * Date of deletion (ISO-8601 format). + */ + deletedAt?: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index 2fb37bde759..a0caf6a492e 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -7,7 +7,9 @@ export * from './baseSearchResponse'; export * from './baseSearchResponseFacetsStats'; export * from './batchObject'; export * from './batchResponse'; +export * from './clearAllSynonymsResponse'; export * from './deleteIndexResponse'; +export * from './deleteSynonymResponse'; export * from './errorBase'; export * from './highlightResult'; export * from './index'; @@ -24,12 +26,17 @@ export * from './rankingInfo'; export * from './rankingInfoMatchedGeoLocation'; export * from './record'; export * from './saveObjectResponse'; +export * from './saveSynonymResponse'; +export * from './saveSynonymsResponse'; export * from './searchHits'; export * from './searchParams'; export * from './searchParamsAsString'; export * from './searchResponse'; +export * from './searchSynonymsResponse'; export * from './setSettingsResponse'; export * from './snippetResult'; +export * from './synonymObject'; +export * from './synonymType'; export interface Authentication { /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts new file mode 100644 index 00000000000..9e64a2f0279 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts @@ -0,0 +1,14 @@ +export type SaveSynonymResponse = { + /** + * TaskID of the indexing task to wait for. + */ + taskID?: number; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt?: Date; + /** + * ObjectID of the inserted object. + */ + id?: string; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts new file mode 100644 index 00000000000..fa59533b83d --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts @@ -0,0 +1,10 @@ +export type SaveSynonymsResponse = { + /** + * TaskID of the indexing task to wait for. + */ + taskID?: number; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt?: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts new file mode 100644 index 00000000000..dff88a53cf3 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts @@ -0,0 +1,12 @@ +import type { SynonymObject } from './synonymObject'; + +export type SearchSynonymsResponse = { + /** + * List of synonym hits. + */ + hits?: SynonymObject[]; + /** + * Number of hits that the search query matched. + */ + nbHits?: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts new file mode 100644 index 00000000000..bd62f7a3cf7 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts @@ -0,0 +1,36 @@ +import type { SynonymType } from './synonymType'; + +/** + * Synonym object. + */ +export type SynonymObject = { + /** + * Unique identifier of the synonym object to be created or updated. + */ + objectID?: string; + type?: SynonymType; + /** + * Words or phrases to be considered equivalent. + */ + synonyms?: string[]; + /** + * Word or phrase to appear in query strings (for onewaysynonym). + */ + input?: string; + /** + * Word or phrase to appear in query strings (for altcorrection1 and altcorrection2). + */ + word?: string; + /** + * Words to be matched in records. + */ + corrections?: string[]; + /** + * Token to be put inside records. + */ + placeholder?: string; + /** + * List of query words that will match the token. + */ + replacements?: string[]; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymType.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymType.ts new file mode 100644 index 00000000000..f6c10b8ee4d --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymType.ts @@ -0,0 +1,10 @@ +/** + * Type of the synonym object. + */ +export enum SynonymType { + Synonym = 'synonym', + Onewaysynonym = 'onewaysynonym', + Altcorrection1 = 'altcorrection1', + Altcorrection2 = 'altcorrection2', + Placeholder = 'placeholder', +} diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index f1957f00196..07af9cb9147 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -1,6 +1,8 @@ import type { BatchObject } from '../model/batchObject'; import type { BatchResponse } from '../model/batchResponse'; +import type { ClearAllSynonymsResponse } from '../model/clearAllSynonymsResponse'; import type { DeleteIndexResponse } from '../model/deleteIndexResponse'; +import type { DeleteSynonymResponse } from '../model/deleteSynonymResponse'; import type { IndexSettings } from '../model/indexSettings'; import type { ListIndicesResponse } from '../model/listIndicesResponse'; import { ApiKeyAuth } from '../model/models'; @@ -9,10 +11,14 @@ import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; import type { OperationIndexObject } from '../model/operationIndexObject'; import type { OperationIndexResponse } from '../model/operationIndexResponse'; import type { SaveObjectResponse } from '../model/saveObjectResponse'; +import type { SaveSynonymResponse } from '../model/saveSynonymResponse'; +import type { SaveSynonymsResponse } from '../model/saveSynonymsResponse'; import type { SearchParams } from '../model/searchParams'; import type { SearchParamsAsString } from '../model/searchParamsAsString'; import type { SearchResponse } from '../model/searchResponse'; +import type { SearchSynonymsResponse } from '../model/searchSynonymsResponse'; import type { SetSettingsResponse } from '../model/setSettingsResponse'; +import type { SynonymObject } from '../model/synonymObject'; import { Transporter } from '../utils/Transporter'; import { shuffle } from '../utils/helpers'; import type { Requester } from '../utils/requester/Requester'; @@ -146,11 +152,51 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Remove all synonyms from an index. + * + * @summary Clear all synonyms. + * @param indexName - The index in which to perform the request. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + */ + clearAllSynonyms( + indexName: string, + forwardToReplicas?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/synonyms/clear'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling clearAllSynonyms.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + const request: Request = { + method: 'POST', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Delete an existing index. * * @summary Delete index. - * @param indexName - The index in which to perform the request. + * @param indexName - The index in which to perform the request. */ deleteIndex(indexName: string): Promise { const path = '/1/indexes/{indexName}'.replace( @@ -178,6 +224,53 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Delete a single synonyms set, identified by the given objectID. + * + * @summary Delete synonym. + * @param indexName - The index in which to perform the request. + * @param objectID - Unique identifier of an object. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + */ + deleteSynonym( + indexName: string, + objectID: string, + forwardToReplicas?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/synonyms/{objectID}' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{objectID}', encodeURIComponent(String(objectID))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling deleteSynonym.' + ); + } + + if (objectID === null || objectID === undefined) { + throw new Error( + 'Required parameter objectID was null or undefined when calling deleteSynonym.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + const request: Request = { + method: 'DELETE', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Retrieve settings of a given indexName. * @@ -209,11 +302,49 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Fetch a synonym object identified by its objectID. + * + * @summary Get synonym. + * @param indexName - The index in which to perform the request. + * @param objectID - Unique identifier of an object. + */ + getSynonym(indexName: string, objectID: string): Promise { + const path = '/1/indexes/{indexName}/synonyms/{objectID}' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{objectID}', encodeURIComponent(String(objectID))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling getSynonym.' + ); + } + + if (objectID === null || objectID === undefined) { + throw new Error( + 'Required parameter objectID was null or undefined when calling getSynonym.' + ); + } + + const request: Request = { + method: 'GET', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * List existing indexes from an application. * * @summary List existing indexes. - * @param page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * @param page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). */ listIndices(page?: number): Promise { const path = '/1/indexes'; @@ -271,7 +402,7 @@ export class SearchApi { * Peforms a copy or a move operation on a index. * * @summary Copy/move index. - * @param indexName - The index in which to perform the request. + * @param indexName - The index in which to perform the request. * @param operationIndexObject - The operationIndexObject. */ operationIndex( @@ -352,6 +483,118 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Create a new synonym object or update the existing synonym object with the given object ID. + * + * @summary Save synonym. + * @param indexName - The index in which to perform the request. + * @param objectID - Unique identifier of an object. + * @param synonymObject - The synonymObject. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + */ + saveSynonym( + indexName: string, + objectID: string, + synonymObject: SynonymObject, + forwardToReplicas?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/synonyms/{objectID}' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{objectID}', encodeURIComponent(String(objectID))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling saveSynonym.' + ); + } + + if (objectID === null || objectID === undefined) { + throw new Error( + 'Required parameter objectID was null or undefined when calling saveSynonym.' + ); + } + + if (synonymObject === null || synonymObject === undefined) { + throw new Error( + 'Required parameter synonymObject was null or undefined when calling saveSynonym.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + const request: Request = { + method: 'PUT', + path, + data: synonymObject, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } + /** + * Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if replaceExistingSynonyms is true. + * + * @summary Save a batch of synonyms. + * @param indexName - The index in which to perform the request. + * @param synonymObject - The synonymObject. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + * @param replaceExistingSynonyms - Replace all synonyms of the index with the ones sent with this request. + */ + saveSynonyms( + indexName: string, + synonymObject: SynonymObject[], + forwardToReplicas?: boolean, + replaceExistingSynonyms?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/synonyms/batch'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling saveSynonyms.' + ); + } + + if (synonymObject === null || synonymObject === undefined) { + throw new Error( + 'Required parameter synonymObject was null or undefined when calling saveSynonyms.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + if (replaceExistingSynonyms !== undefined) { + queryParameters.replaceExistingSynonyms = + replaceExistingSynonyms.toString(); + } + + const request: Request = { + method: 'POST', + path, + data: synonymObject, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Get search results. * @@ -397,6 +640,69 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Search or browse all synonyms, optionally filtering them by type. + * + * @summary Get all synonyms that match a query. + * @param indexName - The index in which to perform the request. + * @param query - Search for specific synonyms matching this string. + * @param type - Only search for specific types of synonyms. + * @param page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * @param hitsPerPage - Maximum number of objects to retrieve. + */ + searchSynonyms( + indexName: string, + query?: string, + type?: + | 'altcorrection1' + | 'altcorrection2' + | 'onewaysynonym' + | 'placeholder' + | 'synonym', + page?: number, + hitsPerPage?: number + ): Promise { + const path = '/1/indexes/{indexName}/synonyms/search'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling searchSynonyms.' + ); + } + + if (query !== undefined) { + queryParameters.query = query.toString(); + } + + if (type !== undefined) { + queryParameters.type = type.toString(); + } + + if (page !== undefined) { + queryParameters.Page = page.toString(); + } + + if (hitsPerPage !== undefined) { + queryParameters.hitsPerPage = hitsPerPage.toString(); + } + + const request: Request = { + method: 'POST', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Update settings of a given indexName. Only specified settings are overridden; unspecified settings are left unchanged. Specifying null for a setting resets it to its default value. * diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index ac0faf7da69..7870e6dc587 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -8,6 +8,15 @@ IndexName: type: string example: 'myIndexName' +ObjectID: + name: objectID + in: path + description: Unique identifier of an object. + required: true + schema: + type: string + example: '123' + # query ForwardToReplicas: in: query @@ -16,7 +25,6 @@ ForwardToReplicas: schema: type: boolean -# query Page: in: query name: Page @@ -26,6 +34,14 @@ Page: nullable: true default: null +HitsPerPage: + in: query + name: hitsPerPage + description: Maximum number of objects to retrieve. + schema: + type: integer + default: 100 + # misc taskID: type: integer @@ -35,6 +51,10 @@ objectID: type: string description: Unique identifier of the object. +id: + type: string + description: objectID of the inserted object. + objectIDs: type: array items: diff --git a/specs/search/paths/synonyms/batchSynonyms.yml b/specs/search/paths/synonyms/batchSynonyms.yml index 6adb517bf4f..ad05525f200 100644 --- a/specs/search/paths/synonyms/batchSynonyms.yml +++ b/specs/search/paths/synonyms/batchSynonyms.yml @@ -1 +1,38 @@ post: + tags: + - search + operationId: saveSynonyms + summary: Save a batch of synonyms. + description: Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if replaceExistingSynonyms is true. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + - $ref: 'parameters.yml#/ReplaceExistingSynonyms' + requestBody: + required: true + content: + application/json: + schema: + $ref: './schemas.yml#/synonymsObject' + responses: + '200': + description: OK + content: + application/json: + schema: + title: saveSynonymsResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/parameters.yml#/taskID' + updatedAt: + $ref: '../../../common/parameters.yml#/updatedAt' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/paths/synonyms/clearAllSynonyms.yml b/specs/search/paths/synonyms/clearAllSynonyms.yml index 6adb517bf4f..00adc17a5d7 100644 --- a/specs/search/paths/synonyms/clearAllSynonyms.yml +++ b/specs/search/paths/synonyms/clearAllSynonyms.yml @@ -1 +1,31 @@ post: + tags: + - search + operationId: clearAllSynonyms + summary: Clear all synonyms. + description: Remove all synonyms from an index. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + responses: + '200': + description: OK + content: + application/json: + schema: + title: clearAllSynonymsResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/parameters.yml#/taskID' + updatedAt: + $ref: '../../../common/parameters.yml#/updatedAt' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/paths/synonyms/parameters.yml b/specs/search/paths/synonyms/parameters.yml new file mode 100644 index 00000000000..b03e75e873f --- /dev/null +++ b/specs/search/paths/synonyms/parameters.yml @@ -0,0 +1,28 @@ +ReplaceExistingSynonyms: + in: query + name: replaceExistingSynonyms + schema: + type: boolean + description: Replace all synonyms of the index with the ones sent with this request. + +Query: + in: query + name: query + description: Search for specific synonyms matching this string. + schema: + type: string + +Type: + in: query + name: type + description: Only search for specific types of synonyms. + schema: + type: string + enum: + [ + 'synonym', + 'onewaysynonym', + 'altcorrection1', + 'altcorrection2', + 'placeholder', + ] diff --git a/specs/search/paths/synonyms/schemas.yml b/specs/search/paths/synonyms/schemas.yml new file mode 100644 index 00000000000..f2ccf66701e --- /dev/null +++ b/specs/search/paths/synonyms/schemas.yml @@ -0,0 +1,69 @@ +synonymsObject: + type: array + description: Array of synonym objects. + items: + $ref: '#/synonymObject' + +synonymObject: + type: object + description: Synonym object. + additionalProperties: false + properties: + objectID: + type: string + description: Unique identifier of the synonym object to be created or updated. + type: + $ref: '#/synonymType' + synonyms: + type: array + items: + type: string + description: Words or phrases to be considered equivalent. + input: + type: string + description: Word or phrase to appear in query strings (for onewaysynonym). + word: + type: string + description: Word or phrase to appear in query strings (for altcorrection1 and altcorrection2). + corrections: + type: array + items: + type: string + description: Words to be matched in records. + placeholder: + type: string + description: Token to be put inside records. + replacements: + type: array + items: + type: string + description: List of query words that will match the token. + required: + - operation + - destination + +synonymType: + type: string + enum: + [ + 'synonym', + 'onewaysynonym', + 'altcorrection1', + 'altcorrection2', + 'placeholder', + ] + description: Type of the synonym object. + +searchSynonymsResponse: + type: object + additionalProperties: true + properties: + hits: + type: array + items: + $ref: '#/synonymObject' + description: List of synonym hits. + nbHits: + type: integer + description: Number of hits that the search query matched + example: 20 diff --git a/specs/search/paths/synonyms/searchSynonyms.yml b/specs/search/paths/synonyms/searchSynonyms.yml index 6adb517bf4f..de119550c72 100644 --- a/specs/search/paths/synonyms/searchSynonyms.yml +++ b/specs/search/paths/synonyms/searchSynonyms.yml @@ -1 +1,27 @@ post: + tags: + - search + operationId: searchSynonyms + summary: Get all synonyms that match a query. + description: Search or browse all synonyms, optionally filtering them by type. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: 'parameters.yml#/Query' + - $ref: 'parameters.yml#/Type' + - $ref: '../../../common/parameters.yml#/Page' + - $ref: '../../../common/parameters.yml#/HitsPerPage' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './schemas.yml#/searchSynonymsResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/paths/synonyms/synonym.yml b/specs/search/paths/synonyms/synonym.yml index 9157e5af9a3..eddf2dc64e5 100644 --- a/specs/search/paths/synonyms/synonym.yml +++ b/specs/search/paths/synonyms/synonym.yml @@ -1,3 +1,98 @@ put: + tags: + - search + operationId: saveSynonym + summary: Save synonym. + description: Create a new synonym object or update the existing synonym object with the given object ID. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ObjectID' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + requestBody: + required: true + content: + application/json: + schema: + $ref: './schemas.yml#/synonymObject' + responses: + '200': + description: OK + content: + application/json: + schema: + title: saveSynonymResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/parameters.yml#/taskID' + updatedAt: + $ref: '../../../common/parameters.yml#/updatedAt' + id: + $ref: '../../../common/parameters.yml#/id' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + get: + tags: + - search + operationId: getSynonym + summary: Get synonym. + description: Fetch a synonym object identified by its objectID. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ObjectID' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './schemas.yml#/synonymObject' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + delete: + tags: + - search + operationId: deleteSynonym + summary: Delete synonym. + description: Delete a single synonyms set, identified by the given objectID. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ObjectID' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + responses: + '200': + description: OK + content: + application/json: + schema: + title: deleteSynonymResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/parameters.yml#/taskID' + deletedAt: + $ref: '../../../common/parameters.yml#/deleteAt' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/spec.yml b/specs/search/spec.yml index 9ca319447a6..4b91551619d 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -64,14 +64,14 @@ paths: # ########################## # ### Synonyms Endpoints ### # ########################## - # /1/indexes/{indexName}/synonyms/{objectID}: - # $ref: './paths/synonyms/synonym.yml' - # /1/indexes/{indexName}/synonyms/batch: - # $ref: './paths/synonyms/batchSynonyms.yml' - # /1/indexes/{indexName}/synonyms/clear: - # $ref: './paths/synonyms/clearAllSynonyms.yml' - # /1/indexes/{indexName}/synonyms/search: - # $ref: './paths/synonyms/searchSynonyms.yml' + /1/indexes/{indexName}/synonyms/{objectID}: + $ref: './paths/synonyms/synonym.yml' + /1/indexes/{indexName}/synonyms/batch: + $ref: './paths/synonyms/batchSynonyms.yml' + /1/indexes/{indexName}/synonyms/clear: + $ref: './paths/synonyms/clearAllSynonyms.yml' + /1/indexes/{indexName}/synonyms/search: + $ref: './paths/synonyms/searchSynonyms.yml' # # ###################### # ### Keys Endpoints ### From a15f12e66c0dfdbcd6d9073ac890b92d76952278 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 10 Dec 2021 11:48:00 +0100 Subject: [PATCH 2/7] fix: first review and first test --- .../client-search/model/models.ts | 3 +- .../model/searchSynonymsResponse.ts | 4 +-- .../model/{synonymObject.ts => synonymHit.ts} | 19 +++++++++--- .../client-search/src/searchApi.ts | 24 +++++++------- specs/search/paths/synonyms/batchSynonyms.yml | 4 +-- .../synonyms/{ => common}/parameters.yml | 0 .../paths/synonyms/{ => common}/schemas.yml | 31 +++++++++---------- .../search/paths/synonyms/searchSynonyms.yml | 6 ++-- specs/search/paths/synonyms/synonym.yml | 4 +-- .../CTS/clients/search/clearAllSynonyms.json | 13 ++++++++ tests/CTS/templates/javascript.mustache | 2 +- 11 files changed, 65 insertions(+), 45 deletions(-) rename clients/algoliasearch-client-javascript/client-search/model/{synonymObject.ts => synonymHit.ts} (66%) rename specs/search/paths/synonyms/{ => common}/parameters.yml (100%) rename specs/search/paths/synonyms/{ => common}/schemas.yml (80%) create mode 100644 tests/CTS/clients/search/clearAllSynonyms.json diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index a0caf6a492e..d837d7d0703 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -35,8 +35,7 @@ export * from './searchResponse'; export * from './searchSynonymsResponse'; export * from './setSettingsResponse'; export * from './snippetResult'; -export * from './synonymObject'; -export * from './synonymType'; +export * from './synonymHit'; export interface Authentication { /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts index dff88a53cf3..a295841c75a 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts @@ -1,10 +1,10 @@ -import type { SynonymObject } from './synonymObject'; +import type { SynonymHit } from './synonymHit'; export type SearchSynonymsResponse = { /** * List of synonym hits. */ - hits?: SynonymObject[]; + hits?: SynonymHit[]; /** * Number of hits that the search query matched. */ diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts similarity index 66% rename from clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts rename to clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts index bd62f7a3cf7..c99a944a72e 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/synonymObject.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts @@ -1,14 +1,15 @@ -import type { SynonymType } from './synonymType'; - /** * Synonym object. */ -export type SynonymObject = { +export type SynonymHit = { /** * Unique identifier of the synonym object to be created or updated. */ objectID?: string; - type?: SynonymType; + /** + * Type of the synonym object. + */ + type?: SynonymHit.TypeEnum; /** * Words or phrases to be considered equivalent. */ @@ -34,3 +35,13 @@ export type SynonymObject = { */ replacements?: string[]; }; + +export namespace SynonymHit { + export enum TypeEnum { + Synonym = 'synonym', + Onewaysynonym = 'onewaysynonym', + Altcorrection1 = 'altcorrection1', + Altcorrection2 = 'altcorrection2', + Placeholder = 'placeholder', + } +} diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index 0f8563d1043..0fd22b66f8c 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -18,7 +18,7 @@ import type { SearchParamsAsString } from '../model/searchParamsAsString'; import type { SearchResponse } from '../model/searchResponse'; import type { SearchSynonymsResponse } from '../model/searchSynonymsResponse'; import type { SetSettingsResponse } from '../model/setSettingsResponse'; -import type { SynonymObject } from '../model/synonymObject'; +import type { SynonymHit } from '../model/synonymHit'; import { Transporter } from '../utils/Transporter'; import { shuffle } from '../utils/helpers'; import type { Requester } from '../utils/requester/Requester'; @@ -310,7 +310,7 @@ export class SearchApi { * @param indexName - The index in which to perform the request. * @param objectID - Unique identifier of an object. */ - getSynonym(indexName: string, objectID: string): Promise { + getSynonym(indexName: string, objectID: string): Promise { const path = '/1/indexes/{indexName}/synonyms/{objectID}' .replace('{indexName}', encodeURIComponent(String(indexName))) .replace('{objectID}', encodeURIComponent(String(objectID))); @@ -490,13 +490,13 @@ export class SearchApi { * @summary Save synonym. * @param indexName - The index in which to perform the request. * @param objectID - Unique identifier of an object. - * @param synonymObject - The synonymObject. + * @param synonymHit - The synonymHit. * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. */ saveSynonym( indexName: string, objectID: string, - synonymObject: SynonymObject, + synonymHit: SynonymHit, forwardToReplicas?: boolean ): Promise { const path = '/1/indexes/{indexName}/synonyms/{objectID}' @@ -517,9 +517,9 @@ export class SearchApi { ); } - if (synonymObject === null || synonymObject === undefined) { + if (synonymHit === null || synonymHit === undefined) { throw new Error( - 'Required parameter synonymObject was null or undefined when calling saveSynonym.' + 'Required parameter synonymHit was null or undefined when calling saveSynonym.' ); } @@ -530,7 +530,7 @@ export class SearchApi { const request: Request = { method: 'PUT', path, - data: synonymObject, + data: synonymHit, }; const requestOptions: RequestOptions = { @@ -545,13 +545,13 @@ export class SearchApi { * * @summary Save a batch of synonyms. * @param indexName - The index in which to perform the request. - * @param synonymObject - The synonymObject. + * @param synonymHit - The synonymHit. * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. * @param replaceExistingSynonyms - Replace all synonyms of the index with the ones sent with this request. */ saveSynonyms( indexName: string, - synonymObject: SynonymObject[], + synonymHit: SynonymHit[], forwardToReplicas?: boolean, replaceExistingSynonyms?: boolean ): Promise { @@ -568,9 +568,9 @@ export class SearchApi { ); } - if (synonymObject === null || synonymObject === undefined) { + if (synonymHit === null || synonymHit === undefined) { throw new Error( - 'Required parameter synonymObject was null or undefined when calling saveSynonyms.' + 'Required parameter synonymHit was null or undefined when calling saveSynonyms.' ); } @@ -586,7 +586,7 @@ export class SearchApi { const request: Request = { method: 'POST', path, - data: synonymObject, + data: synonymHit, }; const requestOptions: RequestOptions = { diff --git a/specs/search/paths/synonyms/batchSynonyms.yml b/specs/search/paths/synonyms/batchSynonyms.yml index ad05525f200..cc5ea628a4d 100644 --- a/specs/search/paths/synonyms/batchSynonyms.yml +++ b/specs/search/paths/synonyms/batchSynonyms.yml @@ -7,13 +7,13 @@ post: parameters: - $ref: '../../../common/parameters.yml#/IndexName' - $ref: '../../../common/parameters.yml#/ForwardToReplicas' - - $ref: 'parameters.yml#/ReplaceExistingSynonyms' + - $ref: 'common/parameters.yml#/ReplaceExistingSynonyms' requestBody: required: true content: application/json: schema: - $ref: './schemas.yml#/synonymsObject' + $ref: 'common/schemas.yml#/synonymHits' responses: '200': description: OK diff --git a/specs/search/paths/synonyms/parameters.yml b/specs/search/paths/synonyms/common/parameters.yml similarity index 100% rename from specs/search/paths/synonyms/parameters.yml rename to specs/search/paths/synonyms/common/parameters.yml diff --git a/specs/search/paths/synonyms/schemas.yml b/specs/search/paths/synonyms/common/schemas.yml similarity index 80% rename from specs/search/paths/synonyms/schemas.yml rename to specs/search/paths/synonyms/common/schemas.yml index f2ccf66701e..16651f80dd1 100644 --- a/specs/search/paths/synonyms/schemas.yml +++ b/specs/search/paths/synonyms/common/schemas.yml @@ -1,10 +1,10 @@ -synonymsObject: +synonymHits: type: array description: Array of synonym objects. items: - $ref: '#/synonymObject' + $ref: '#/synonymHit' -synonymObject: +synonymHit: type: object description: Synonym object. additionalProperties: false @@ -13,7 +13,16 @@ synonymObject: type: string description: Unique identifier of the synonym object to be created or updated. type: - $ref: '#/synonymType' + type: string + description: Type of the synonym object. + enum: + [ + 'synonym', + 'onewaysynonym', + 'altcorrection1', + 'altcorrection2', + 'placeholder', + ] synonyms: type: array items: @@ -42,18 +51,6 @@ synonymObject: - operation - destination -synonymType: - type: string - enum: - [ - 'synonym', - 'onewaysynonym', - 'altcorrection1', - 'altcorrection2', - 'placeholder', - ] - description: Type of the synonym object. - searchSynonymsResponse: type: object additionalProperties: true @@ -61,7 +58,7 @@ searchSynonymsResponse: hits: type: array items: - $ref: '#/synonymObject' + $ref: '#/synonymHit' description: List of synonym hits. nbHits: type: integer diff --git a/specs/search/paths/synonyms/searchSynonyms.yml b/specs/search/paths/synonyms/searchSynonyms.yml index de119550c72..c87a056bcaf 100644 --- a/specs/search/paths/synonyms/searchSynonyms.yml +++ b/specs/search/paths/synonyms/searchSynonyms.yml @@ -6,8 +6,8 @@ post: description: Search or browse all synonyms, optionally filtering them by type. parameters: - $ref: '../../../common/parameters.yml#/IndexName' - - $ref: 'parameters.yml#/Query' - - $ref: 'parameters.yml#/Type' + - $ref: 'common/parameters.yml#/Query' + - $ref: 'common/parameters.yml#/Type' - $ref: '../../../common/parameters.yml#/Page' - $ref: '../../../common/parameters.yml#/HitsPerPage' responses: @@ -16,7 +16,7 @@ post: content: application/json: schema: - $ref: './schemas.yml#/searchSynonymsResponse' + $ref: 'common/schemas.yml#/searchSynonymsResponse' '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/specs/search/paths/synonyms/synonym.yml b/specs/search/paths/synonyms/synonym.yml index eddf2dc64e5..1351460275a 100644 --- a/specs/search/paths/synonyms/synonym.yml +++ b/specs/search/paths/synonyms/synonym.yml @@ -13,7 +13,7 @@ put: content: application/json: schema: - $ref: './schemas.yml#/synonymObject' + $ref: 'common/schemas.yml#/synonymHit' responses: '200': description: OK @@ -54,7 +54,7 @@ get: content: application/json: schema: - $ref: './schemas.yml#/synonymObject' + $ref: './common/schemas.yml#/synonymHit' '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/tests/CTS/clients/search/clearAllSynonyms.json b/tests/CTS/clients/search/clearAllSynonyms.json new file mode 100644 index 00000000000..a1d6dbb09e2 --- /dev/null +++ b/tests/CTS/clients/search/clearAllSynonyms.json @@ -0,0 +1,13 @@ +[ + { + "testName": "clearAllSynonyms", + "method": "clearAllSynonyms", + "parameters": [ + "indexName" + ], + "request": { + "path": "/1/indexes/indexName/synonyms/clear", + "method": "POST" + } + } +] diff --git a/tests/CTS/templates/javascript.mustache b/tests/CTS/templates/javascript.mustache index 77bad11f3e3..ed343b797dc 100644 --- a/tests/CTS/templates/javascript.mustache +++ b/tests/CTS/templates/javascript.mustache @@ -9,7 +9,7 @@ describe('Common Test Suite', () => { expect(req).toMatchObject({ path: '{{{request.path}}}', method: '{{{request.method}}}', - data: {{{request.data}}}, + {{#data}}data: {{{request.data}}},{{/data}} }) }); From 8a2e1e1536d50633b180d079832e49468754c50d Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 10 Dec 2021 16:57:25 +0100 Subject: [PATCH 3/7] feat: add CTS tests --- tests/CTS/clients/search/deleteSynonym.json | 14 +++ tests/CTS/clients/search/getSynonym.json | 14 +++ tests/CTS/clients/search/saveSynonym.json | 28 +++++ tests/CTS/clients/search/saveSynonyms.json | 45 ++++++++ tests/CTS/clients/search/searchSynonyms.json | 15 +++ tests/CTS/templates/javascript.mustache | 3 +- tests/output/javascript/search.test.ts | 104 +++++++++++++++++++ 7 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 tests/CTS/clients/search/deleteSynonym.json create mode 100644 tests/CTS/clients/search/getSynonym.json create mode 100644 tests/CTS/clients/search/saveSynonym.json create mode 100644 tests/CTS/clients/search/saveSynonyms.json create mode 100644 tests/CTS/clients/search/searchSynonyms.json diff --git a/tests/CTS/clients/search/deleteSynonym.json b/tests/CTS/clients/search/deleteSynonym.json new file mode 100644 index 00000000000..7e0d7d698b2 --- /dev/null +++ b/tests/CTS/clients/search/deleteSynonym.json @@ -0,0 +1,14 @@ +[ + { + "testName": "deleteSynonym", + "method": "deleteSynonym", + "parameters": [ + "indexName", + "id1" + ], + "request": { + "path": "/1/indexes/indexName/synonyms/id1", + "method": "DELETE" + } + } +] diff --git a/tests/CTS/clients/search/getSynonym.json b/tests/CTS/clients/search/getSynonym.json new file mode 100644 index 00000000000..53a36a3f2a0 --- /dev/null +++ b/tests/CTS/clients/search/getSynonym.json @@ -0,0 +1,14 @@ +[ + { + "testName": "getSynonym", + "method": "getSynonym", + "parameters": [ + "indexName", + "id1" + ], + "request": { + "path": "/1/indexes/indexName/synonyms/id1", + "method": "GET" + } + } +] diff --git a/tests/CTS/clients/search/saveSynonym.json b/tests/CTS/clients/search/saveSynonym.json new file mode 100644 index 00000000000..0c8a437d6a6 --- /dev/null +++ b/tests/CTS/clients/search/saveSynonym.json @@ -0,0 +1,28 @@ +[ + { + "testName": "saveSynonym", + "method": "saveSynonym", + "parameters": [ + "indexName", + "id1", + { + "objectID" : "id1", + "type": "synonym", + "synonyms": ["car", "vehicule", "auto"] + }, + true + ], + "request": { + "path": "/1/indexes/indexName/synonyms/id1", + "method": "PUT", + "data": { + "synonymHit": { + "objectID" : "id1", + "type": "synonym", + "synonyms": ["car", "vehicule", "auto"] + }, + "ForwardToReplicas": true + } + } + } +] diff --git a/tests/CTS/clients/search/saveSynonyms.json b/tests/CTS/clients/search/saveSynonyms.json new file mode 100644 index 00000000000..78b50dfe488 --- /dev/null +++ b/tests/CTS/clients/search/saveSynonyms.json @@ -0,0 +1,45 @@ +[ + { + "testName": "saveSynonyms", + "method": "saveSynonyms", + "parameters": [ + "indexName", + [ + { + "objectID" : "id1", + "type": "synonym", + "synonyms": ["car", "vehicule", "auto"] + }, + { + "objectID" : "id2", + "type": "onewaysynonym", + "input": "iphone", + "synonyms": ["ephone", "aphone", "yphone"] + } + ], + true, + false + ], + "request": { + "path": "/1/indexes/indexName/synonyms/batch", + "method": "POST", + "data": { + "synonymHit": [ + { + "objectID" : "id1", + "type": "synonym", + "synonyms": ["car", "vehicule", "auto"] + }, + { + "objectID" : "id2", + "type": "onewaysynonym", + "input": "iphone", + "synonyms": ["ephone", "aphone", "yphone"] + } + ], + "ForwardToReplicas": true, + "ReplaceExistingSynonyms": false + } + } + } +] diff --git a/tests/CTS/clients/search/searchSynonyms.json b/tests/CTS/clients/search/searchSynonyms.json new file mode 100644 index 00000000000..3836ec78601 --- /dev/null +++ b/tests/CTS/clients/search/searchSynonyms.json @@ -0,0 +1,15 @@ +[ + { + "testName": "searchSynonyms", + "method": "searchSynonyms", + "parameters": [ + "indexName", + "queryString", + "onewaysynonym" + ], + "request": { + "path": "/1/indexes/indexName/synonyms/search", + "method": "POST" + } + } +] diff --git a/tests/CTS/templates/javascript.mustache b/tests/CTS/templates/javascript.mustache index ed343b797dc..a9279f15c40 100644 --- a/tests/CTS/templates/javascript.mustache +++ b/tests/CTS/templates/javascript.mustache @@ -1,3 +1,4 @@ +// @ts-nocheck import { {{client}}, EchoRequester } from '{{{import}}}'; describe('Common Test Suite', () => { @@ -9,7 +10,7 @@ describe('Common Test Suite', () => { expect(req).toMatchObject({ path: '{{{request.path}}}', method: '{{{request.method}}}', - {{#data}}data: {{{request.data}}},{{/data}} + {{#request.data}}data: {{{request.data}}},{{/request.data}} }) }); diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index 7765d0557ed..fee71e30f6e 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import { SearchApi, EchoRequester } from '@algolia/client-search'; describe('Common Test Suite', () => { @@ -7,6 +8,68 @@ describe('Common Test Suite', () => { { requester: new EchoRequester() } ); + test('searchSynonyms', async () => { + const req = await client.searchSynonyms( + 'indexName', + 'queryString', + 'onewaysynonym' + ); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/synonyms/search', + method: 'POST', + }); + }); + + test('saveSynonyms', async () => { + const req = await client.saveSynonyms( + 'indexName', + [ + { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + { + objectID: 'id2', + type: 'onewaysynonym', + input: 'iphone', + synonyms: ['ephone', 'aphone', 'yphone'], + }, + ], + true, + false + ); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/synonyms/batch', + method: 'POST', + data: { + synonymHit: [ + { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + { + objectID: 'id2', + type: 'onewaysynonym', + input: 'iphone', + synonyms: ['ephone', 'aphone', 'yphone'], + }, + ], + ForwardToReplicas: true, + ReplaceExistingSynonyms: false, + }, + }); + }); + + test('getSynonym', async () => { + const req = await client.getSynonym('indexName', 'id1'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/synonyms/id1', + method: 'GET', + }); + }); + test('search', async () => { const req = await client.search('indexName', { query: 'queryString' }); expect(req).toMatchObject({ @@ -15,4 +78,45 @@ describe('Common Test Suite', () => { data: { query: 'queryString' }, }); }); + + test('clearAllSynonyms', async () => { + const req = await client.clearAllSynonyms('indexName'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/synonyms/clear', + method: 'POST', + }); + }); + + test('deleteSynonym', async () => { + const req = await client.deleteSynonym('indexName', 'id1'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/synonyms/id1', + method: 'DELETE', + }); + }); + + test('saveSynonym', async () => { + const req = await client.saveSynonym( + 'indexName', + 'id1', + { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + true + ); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/synonyms/id1', + method: 'PUT', + data: { + synonymHit: { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + ForwardToReplicas: true, + }, + }); + }); }); From 7e912b6867c6bee08be544a2870872868db265d1 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 10 Dec 2021 17:31:35 +0100 Subject: [PATCH 4/7] feat: add highlighted results --- .../client-search/model/highlightedSynonym.ts | 26 +++++++++++++++ .../client-search/model/models.ts | 2 ++ .../client-search/model/synonymHit.ts | 3 ++ .../model/synonymHitHighlightResult.ts | 9 ++++++ .../search/paths/synonyms/common/schemas.yml | 32 +++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 clients/algoliasearch-client-javascript/client-search/model/highlightedSynonym.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts diff --git a/clients/algoliasearch-client-javascript/client-search/model/highlightedSynonym.ts b/clients/algoliasearch-client-javascript/client-search/model/highlightedSynonym.ts new file mode 100644 index 00000000000..7b163e856bd --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/highlightedSynonym.ts @@ -0,0 +1,26 @@ +export type HighlightedSynonym = { + /** + * Markup text with occurrences highlighted. + */ + value?: string; + /** + * Indicates how well the attribute matched the search query. + */ + matchLevel?: HighlightedSynonym.MatchLevelEnum; + /** + * List of words from the query that matched the object. + */ + matchedWords?: string[]; + /** + * Whether the entire attribute value is highlighted. + */ + fullyHighlighted?: boolean; +}; + +export namespace HighlightedSynonym { + export enum MatchLevelEnum { + None = 'none', + Partial = 'partial', + Full = 'full', + } +} diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index d837d7d0703..1ec08058ac8 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -12,6 +12,7 @@ export * from './deleteIndexResponse'; export * from './deleteSynonymResponse'; export * from './errorBase'; export * from './highlightResult'; +export * from './highlightedSynonym'; export * from './index'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; @@ -36,6 +37,7 @@ export * from './searchSynonymsResponse'; export * from './setSettingsResponse'; export * from './snippetResult'; export * from './synonymHit'; +export * from './synonymHitHighlightResult'; export interface Authentication { /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts index c99a944a72e..6a137ca98d9 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts @@ -1,3 +1,5 @@ +import type { SynonymHitHighlightResult } from './synonymHitHighlightResult'; + /** * Synonym object. */ @@ -34,6 +36,7 @@ export type SynonymHit = { * List of query words that will match the token. */ replacements?: string[]; + _highlightResult?: SynonymHitHighlightResult; }; export namespace SynonymHit { diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts new file mode 100644 index 00000000000..31cfde313ad --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts @@ -0,0 +1,9 @@ +import type { HighlightedSynonym } from './highlightedSynonym'; + +/** + * Highlighted results. + */ +export type SynonymHitHighlightResult = { + type?: HighlightedSynonym; + synonyms?: HighlightedSynonym[]; +}; diff --git a/specs/search/paths/synonyms/common/schemas.yml b/specs/search/paths/synonyms/common/schemas.yml index 16651f80dd1..689b3224f1b 100644 --- a/specs/search/paths/synonyms/common/schemas.yml +++ b/specs/search/paths/synonyms/common/schemas.yml @@ -47,10 +47,42 @@ synonymHit: items: type: string description: List of query words that will match the token. + _highlightResult: + type: object + description: Highlighted results + additionalProperties: false + properties: + type: + $ref: '#/highlightedSynonym' + synonyms: + type: array + items: + $ref: '#/highlightedSynonym' required: - operation - destination +highlightedSynonym: + type: object + additionalProperties: false + properties: + value: + type: string + description: Markup text with occurrences highlighted. + example: 'George Clooney' + matchLevel: + type: string + description: Indicates how well the attribute matched the search query. + enum: [none, partial, full] + matchedWords: + type: array + description: List of words from the query that matched the object. + items: + type: string + fullyHighlighted: + type: boolean + description: Whether the entire attribute value is highlighted. + searchSynonymsResponse: type: object additionalProperties: true From 3ae0575cc2c1973970f60d6078dcda41e2c0a191 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Mon, 13 Dec 2021 16:24:08 +0100 Subject: [PATCH 5/7] fix: changes after review --- .../model/clearAllSynonymsResponse.ts | 4 +-- .../model/deleteSynonymResponse.ts | 4 +-- .../client-search/model/models.ts | 1 - .../model/saveSynonymResponse.ts | 6 ++-- .../model/saveSynonymsResponse.ts | 4 +-- .../model/searchSynonymsResponse.ts | 2 +- .../model/synonymHitHighlightResult.ts | 6 ++-- specs/common/parameters.yml | 9 +++++ .../search/common/schemas/SearchResponse.yml | 9 +++-- specs/search/paths/synonyms/batchSynonyms.yml | 3 ++ .../paths/synonyms/clearAllSynonyms.yml | 3 ++ .../paths/synonyms/common/parameters.yml | 1 + .../search/paths/synonyms/common/schemas.yml | 34 +++---------------- .../search/paths/synonyms/searchSynonyms.yml | 2 +- specs/search/paths/synonyms/synonym.yml | 7 ++++ tests/CTS/clients/search/saveSynonym.json | 3 +- tests/CTS/clients/search/saveSynonyms.json | 30 +++++++--------- 17 files changed, 61 insertions(+), 67 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts index 18df9a1f9c5..8dc07e6503e 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/clearAllSynonymsResponse.ts @@ -2,9 +2,9 @@ export type ClearAllSynonymsResponse = { /** * TaskID of the indexing task to wait for. */ - taskID?: number; + taskID: number; /** * Date of last update (ISO-8601 format). */ - updatedAt?: Date; + updatedAt: Date; }; diff --git a/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts index a0e2a469232..575406c024a 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/deleteSynonymResponse.ts @@ -2,9 +2,9 @@ export type DeleteSynonymResponse = { /** * TaskID of the indexing task to wait for. */ - taskID?: number; + taskID: number; /** * Date of deletion (ISO-8601 format). */ - deletedAt?: Date; + deletedAt: Date; }; diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index 1ec08058ac8..a832ec37140 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -12,7 +12,6 @@ export * from './deleteIndexResponse'; export * from './deleteSynonymResponse'; export * from './errorBase'; export * from './highlightResult'; -export * from './highlightedSynonym'; export * from './index'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; diff --git a/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts index 9e64a2f0279..35979a159c9 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymResponse.ts @@ -2,13 +2,13 @@ export type SaveSynonymResponse = { /** * TaskID of the indexing task to wait for. */ - taskID?: number; + taskID: number; /** * Date of last update (ISO-8601 format). */ - updatedAt?: Date; + updatedAt: Date; /** * ObjectID of the inserted object. */ - id?: string; + id: string; }; diff --git a/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts index fa59533b83d..fe37f948a04 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/saveSynonymsResponse.ts @@ -2,9 +2,9 @@ export type SaveSynonymsResponse = { /** * TaskID of the indexing task to wait for. */ - taskID?: number; + taskID: number; /** * Date of last update (ISO-8601 format). */ - updatedAt?: Date; + updatedAt: Date; }; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts index a295841c75a..d8a8318ff63 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts @@ -2,7 +2,7 @@ import type { SynonymHit } from './synonymHit'; export type SearchSynonymsResponse = { /** - * List of synonym hits. + * Array of synonym objects. */ hits?: SynonymHit[]; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts index 31cfde313ad..6d475481437 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymHitHighlightResult.ts @@ -1,9 +1,9 @@ -import type { HighlightedSynonym } from './highlightedSynonym'; +import type { HighlightResult } from './highlightResult'; /** * Highlighted results. */ export type SynonymHitHighlightResult = { - type?: HighlightedSynonym; - synonyms?: HighlightedSynonym[]; + type?: HighlightResult; + synonyms?: HighlightResult[]; }; diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index 7870e6dc587..7034d231c1d 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -34,6 +34,15 @@ Page: nullable: true default: null +PageDefault0: + in: query + name: Page + description: Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + schema: + type: integer + nullable: true + default: 0 + HitsPerPage: in: query name: hitsPerPage diff --git a/specs/search/common/schemas/SearchResponse.yml b/specs/search/common/schemas/SearchResponse.yml index d05cff23f13..c4d7756e62c 100644 --- a/specs/search/common/schemas/SearchResponse.yml +++ b/specs/search/common/schemas/SearchResponse.yml @@ -12,6 +12,11 @@ searchHits: items: $ref: 'Record.yml#/record' +nbHits: + type: integer + description: Number of hits that the search query matched + example: 20 + baseSearchResponse: type: object additionalProperties: false @@ -90,9 +95,7 @@ baseSearchResponse: type: string description: Used to return warnings about the query. nbHits: - type: integer - description: Number of hits that the search query matched - example: 20 + $ref: '#/nbHits' nbPages: type: integer description: Number of pages available for the current query diff --git a/specs/search/paths/synonyms/batchSynonyms.yml b/specs/search/paths/synonyms/batchSynonyms.yml index cc5ea628a4d..b26c6acaace 100644 --- a/specs/search/paths/synonyms/batchSynonyms.yml +++ b/specs/search/paths/synonyms/batchSynonyms.yml @@ -28,6 +28,9 @@ post: $ref: '../../../common/parameters.yml#/taskID' updatedAt: $ref: '../../../common/parameters.yml#/updatedAt' + required: + - taskID + - updatedAt '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/specs/search/paths/synonyms/clearAllSynonyms.yml b/specs/search/paths/synonyms/clearAllSynonyms.yml index 00adc17a5d7..9a992969f81 100644 --- a/specs/search/paths/synonyms/clearAllSynonyms.yml +++ b/specs/search/paths/synonyms/clearAllSynonyms.yml @@ -21,6 +21,9 @@ post: $ref: '../../../common/parameters.yml#/taskID' updatedAt: $ref: '../../../common/parameters.yml#/updatedAt' + required: + - taskID + - updatedAt '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/specs/search/paths/synonyms/common/parameters.yml b/specs/search/paths/synonyms/common/parameters.yml index b03e75e873f..a2232c6cc6f 100644 --- a/specs/search/paths/synonyms/common/parameters.yml +++ b/specs/search/paths/synonyms/common/parameters.yml @@ -11,6 +11,7 @@ Query: description: Search for specific synonyms matching this string. schema: type: string + default: '' Type: in: query diff --git a/specs/search/paths/synonyms/common/schemas.yml b/specs/search/paths/synonyms/common/schemas.yml index 689b3224f1b..8980d23f078 100644 --- a/specs/search/paths/synonyms/common/schemas.yml +++ b/specs/search/paths/synonyms/common/schemas.yml @@ -53,46 +53,20 @@ synonymHit: additionalProperties: false properties: type: - $ref: '#/highlightedSynonym' + $ref: '../../../common/schemas/Record.yml#/highlightResult' synonyms: type: array items: - $ref: '#/highlightedSynonym' + $ref: '../../../common/schemas/Record.yml#/highlightResult' required: - operation - destination -highlightedSynonym: - type: object - additionalProperties: false - properties: - value: - type: string - description: Markup text with occurrences highlighted. - example: 'George Clooney' - matchLevel: - type: string - description: Indicates how well the attribute matched the search query. - enum: [none, partial, full] - matchedWords: - type: array - description: List of words from the query that matched the object. - items: - type: string - fullyHighlighted: - type: boolean - description: Whether the entire attribute value is highlighted. - searchSynonymsResponse: type: object additionalProperties: true properties: hits: - type: array - items: - $ref: '#/synonymHit' - description: List of synonym hits. + $ref: '#/synonymHits' nbHits: - type: integer - description: Number of hits that the search query matched - example: 20 + $ref: '../../../common/schemas/SearchResponse.yml#/nbHits' diff --git a/specs/search/paths/synonyms/searchSynonyms.yml b/specs/search/paths/synonyms/searchSynonyms.yml index c87a056bcaf..2cd0ffaf89b 100644 --- a/specs/search/paths/synonyms/searchSynonyms.yml +++ b/specs/search/paths/synonyms/searchSynonyms.yml @@ -8,7 +8,7 @@ post: - $ref: '../../../common/parameters.yml#/IndexName' - $ref: 'common/parameters.yml#/Query' - $ref: 'common/parameters.yml#/Type' - - $ref: '../../../common/parameters.yml#/Page' + - $ref: '../../../common/parameters.yml#/PageDefault0' - $ref: '../../../common/parameters.yml#/HitsPerPage' responses: '200': diff --git a/specs/search/paths/synonyms/synonym.yml b/specs/search/paths/synonyms/synonym.yml index 1351460275a..88401016761 100644 --- a/specs/search/paths/synonyms/synonym.yml +++ b/specs/search/paths/synonyms/synonym.yml @@ -30,6 +30,10 @@ put: $ref: '../../../common/parameters.yml#/updatedAt' id: $ref: '../../../common/parameters.yml#/id' + required: + - taskID + - updatedAt + - id '400': $ref: '../../../common/responses/BadRequest.yml' '402': @@ -88,6 +92,9 @@ delete: $ref: '../../../common/parameters.yml#/taskID' deletedAt: $ref: '../../../common/parameters.yml#/deleteAt' + required: + - taskID + - deletedAt '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/tests/CTS/clients/search/saveSynonym.json b/tests/CTS/clients/search/saveSynonym.json index 0c8a437d6a6..257067b2729 100644 --- a/tests/CTS/clients/search/saveSynonym.json +++ b/tests/CTS/clients/search/saveSynonym.json @@ -20,8 +20,7 @@ "objectID" : "id1", "type": "synonym", "synonyms": ["car", "vehicule", "auto"] - }, - "ForwardToReplicas": true + } } } } diff --git a/tests/CTS/clients/search/saveSynonyms.json b/tests/CTS/clients/search/saveSynonyms.json index 78b50dfe488..531ed9e5170 100644 --- a/tests/CTS/clients/search/saveSynonyms.json +++ b/tests/CTS/clients/search/saveSynonyms.json @@ -23,23 +23,19 @@ "request": { "path": "/1/indexes/indexName/synonyms/batch", "method": "POST", - "data": { - "synonymHit": [ - { - "objectID" : "id1", - "type": "synonym", - "synonyms": ["car", "vehicule", "auto"] - }, - { - "objectID" : "id2", - "type": "onewaysynonym", - "input": "iphone", - "synonyms": ["ephone", "aphone", "yphone"] - } - ], - "ForwardToReplicas": true, - "ReplaceExistingSynonyms": false - } + "data": [ + { + "objectID" : "id1", + "type": "synonym", + "synonyms": ["car", "vehicule", "auto"] + }, + { + "objectID" : "id2", + "type": "onewaysynonym", + "input": "iphone", + "synonyms": ["ephone", "aphone", "yphone"] + } + ] } } ] From 2d5ba0ad50727832731d26ce2a8ea854329c6562 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Mon, 13 Dec 2021 16:48:00 +0100 Subject: [PATCH 6/7] fix: cts test --- tests/CTS/clients/search/saveSynonym.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/CTS/clients/search/saveSynonym.json b/tests/CTS/clients/search/saveSynonym.json index 257067b2729..ecec571c2e0 100644 --- a/tests/CTS/clients/search/saveSynonym.json +++ b/tests/CTS/clients/search/saveSynonym.json @@ -16,11 +16,9 @@ "path": "/1/indexes/indexName/synonyms/id1", "method": "PUT", "data": { - "synonymHit": { - "objectID" : "id1", - "type": "synonym", - "synonyms": ["car", "vehicule", "auto"] - } + "objectID" : "id1", + "type": "synonym", + "synonyms": ["car", "vehicule", "auto"] } } } From b0ed3e4b2c93b359847366bc64964648a244d964 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Tue, 14 Dec 2021 10:16:32 +0100 Subject: [PATCH 7/7] fix: last changes --- .../client-search/model/searchSynonymsResponse.ts | 4 ++-- .../client-search/model/synonymHit.ts | 4 ++-- specs/search/paths/synonyms/common/schemas.yml | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts index d8a8318ff63..b50c74feac1 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchSynonymsResponse.ts @@ -4,9 +4,9 @@ export type SearchSynonymsResponse = { /** * Array of synonym objects. */ - hits?: SynonymHit[]; + hits: SynonymHit[]; /** * Number of hits that the search query matched. */ - nbHits?: number; + nbHits: number; }; diff --git a/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts b/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts index 6a137ca98d9..990865f1ca5 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/synonymHit.ts @@ -7,11 +7,11 @@ export type SynonymHit = { /** * Unique identifier of the synonym object to be created or updated. */ - objectID?: string; + objectID: string; /** * Type of the synonym object. */ - type?: SynonymHit.TypeEnum; + type: SynonymHit.TypeEnum; /** * Words or phrases to be considered equivalent. */ diff --git a/specs/search/paths/synonyms/common/schemas.yml b/specs/search/paths/synonyms/common/schemas.yml index 8980d23f078..ec441a370ef 100644 --- a/specs/search/paths/synonyms/common/schemas.yml +++ b/specs/search/paths/synonyms/common/schemas.yml @@ -59,8 +59,8 @@ synonymHit: items: $ref: '../../../common/schemas/Record.yml#/highlightResult' required: - - operation - - destination + - objectID + - type searchSynonymsResponse: type: object @@ -70,3 +70,6 @@ searchSynonymsResponse: $ref: '#/synonymHits' nbHits: $ref: '../../../common/schemas/SearchResponse.yml#/nbHits' + required: + - hits + - nbHits