diff --git a/.github/.cache_version b/.github/.cache_version index b0f3d96f87..59e9e60491 100644 --- a/.github/.cache_version +++ b/.github/.cache_version @@ -1 +1 @@ -1.0.8 +1.0.11 diff --git a/specs/search/paths/synonyms/searchSynonyms.yml b/specs/search/paths/synonyms/searchSynonyms.yml index dab65babd8..91f67b7451 100644 --- a/specs/search/paths/synonyms/searchSynonyms.yml +++ b/specs/search/paths/synonyms/searchSynonyms.yml @@ -10,9 +10,6 @@ post: description: Search for synonyms in your index. You can control and filter the search with parameters. To get all synonyms, send an empty request body. parameters: - $ref: '../../../common/parameters.yml#/IndexName' - - $ref: './common/parameters.yml#/Type' - - $ref: '../../../common/parameters.yml#/PageDefault0' - - $ref: '../../../common/parameters.yml#/HitsPerPage' requestBody: description: Body of the `searchSynonyms` operation. content: @@ -24,6 +21,12 @@ post: properties: query: $ref: '../../../common/schemas/SearchParams.yml#/query' + type: + $ref: './common/parameters.yml#/SynonymType' + page: + $ref: '../../../common/schemas/SearchParams.yml#/page' + hitsPerPage: + $ref: '../../../common/schemas/IndexSettings.yml#/hitsPerPage' responses: '200': description: OK diff --git a/templates/java/api_helpers.mustache b/templates/java/api_helpers.mustache index 63a204355f..552c46ffc3 100644 --- a/templates/java/api_helpers.mustache +++ b/templates/java/api_helpers.mustache @@ -248,18 +248,19 @@ public Iterable browseObjects(String indexName, BrowseParamsObject params * Helper: Returns an iterator on top of the `searchSynonyms` method. * * @param indexName The index in which to perform the request. - * @param type The synonym type. (optional) * @param params The `searchSynonyms` parameters. (optional) * @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional) */ -public Iterable browseSynonyms(String indexName, SynonymType type, SearchSynonymsParams params, RequestOptions requestOptions) { +public Iterable browseSynonyms(String indexName, SearchSynonymsParams params, RequestOptions requestOptions) { final Holder currentPage = new Holder<>(0); - final int hitsPerPage = 1000; + + params.setPage(0); + params.setHitsPerPage(1000); return AlgoliaIterableHelper.createIterable( () -> { - SearchSynonymsResponse response = this.searchSynonyms(indexName, type, currentPage.value, hitsPerPage, params, requestOptions); - currentPage.value = response.getNbHits() < hitsPerPage ? null : currentPage.value + 1; + SearchSynonymsResponse response = this.searchSynonyms(indexName, params, requestOptions); + currentPage.value = response.getNbHits() < params.getHitsPerPage() ? null : currentPage.value + 1; return response.getHits().iterator(); }, () -> currentPage.value != null @@ -270,11 +271,10 @@ public Iterable browseSynonyms(String indexName, SynonymType type, S * Helper: Returns an iterator on top of the `searchSynonyms` method. * * @param indexName The index in which to perform the request. - * @param type The synonym type. (optional) * @param params The `searchSynonyms` parameters .(optional) */ -public Iterable browseSynonyms(String indexName, SynonymType type, SearchSynonymsParams params) { - return browseSynonyms(indexName, type, params, null); +public Iterable browseSynonyms(String indexName, SearchSynonymsParams params) { + return browseSynonyms(indexName, params, null); } @@ -284,7 +284,7 @@ public Iterable browseSynonyms(String indexName, SynonymType type, S * @param indexName The index in which to perform the request. */ public Iterable browseSynonyms(String indexName) { - return browseSynonyms(indexName, null, null, null); + return browseSynonyms(indexName, null, null); } /** diff --git a/templates/javascript/clients/client/api/helpers.mustache b/templates/javascript/clients/client/api/helpers.mustache index 0c4ffad829..7949b4cca0 100644 --- a/templates/javascript/clients/client/api/helpers.mustache +++ b/templates/javascript/clients/client/api/helpers.mustache @@ -196,31 +196,34 @@ browseRules( * @param browseObjects.indexName - The index in which to perform the request. * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000). * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`. + * @param browseObjects.searchSynonymsParams - The `searchSynonyms` method parameters. * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions. */ browseSynonyms( { indexName, - validate, - aggregator, - ...browseSynonymsOptions + searchSynonymsParams, + ...browseSynonymsOptions, }: BrowseOptions & SearchSynonymsProps, requestOptions?: RequestOptions ): Promise { const params = { + page: 0, + ...searchSynonymsParams, hitsPerPage: 1000, - ...browseSynonymsOptions, }; return createIterablePromise({ func: (previousResponse) => { return this.searchSynonyms( { - ...params, indexName, - page: previousResponse - ? previousResponse.page + 1 - : browseSynonymsOptions.page || 0, + searchSynonymsParams: { + ...params, + page: previousResponse + ? previousResponse.page + 1 + : params.page, + }, }, requestOptions ); diff --git a/templates/python/search_helpers.mustache b/templates/python/search_helpers.mustache index ee7b4ae00a..71d20a3e9a 100644 --- a/templates/python/search_helpers.mustache +++ b/templates/python/search_helpers.mustache @@ -136,28 +136,25 @@ self, index_name: str, aggregator: Optional[Callable[[SearchSynonymsResponse], None]], - synonym_type: Optional[SynonymType] = None, - page: Optional[int] = 0, - hits_per_page: Optional[int] = 1000, search_synonyms_params: Optional[SearchSynonymsParams] = SearchSynonymsParams(), request_options: Optional[Union[dict, RequestOptions]] = None, ) -> SearchSynonymsResponse: """ Helper: Iterate on the `search_synonyms` method of the client to allow aggregating synonyms of an index. """ + search_synonyms_params.page = 0 + search_synonyms_params.hits_per_page = 1000 + async def _func(_prev: SearchRulesResponse) -> SearchRulesResponse: if _prev is not None: search_synonyms_params.page = _prev.page + 1 return await self.search_synonyms( index_name=index_name, - type=synonym_type, - page=page, - hits_per_page=hits_per_page, search_synonyms_params=search_synonyms_params, request_options=request_options, ) return await create_iterable( func=_func, - validate=lambda _resp: _resp.nb_hits < hits_per_page, + validate=lambda _resp: _resp.nb_hits < search_synonyms_params.hits_per_page, aggregator=aggregator, - ) + ) \ No newline at end of file diff --git a/tests/CTS/requests/search/searchSynonyms.json b/tests/CTS/requests/search/searchSynonyms.json index a9c5575772..6cca27be1e 100644 --- a/tests/CTS/requests/search/searchSynonyms.json +++ b/tests/CTS/requests/search/searchSynonyms.json @@ -13,23 +13,21 @@ "testName": "searchSynonyms with all parameters", "parameters": { "indexName": "indexName", - "type": "altcorrection1", - "page": 10, - "hitsPerPage": 10, "searchSynonymsParams": { - "query": "myQuery" + "query": "myQuery", + "type": "altcorrection1", + "page": 10, + "hitsPerPage": 10 } }, "request": { "path": "/1/indexes/indexName/synonyms/search", "method": "POST", "body": { - "query": "myQuery" - }, - "queryParameters": { + "query": "myQuery", "type": "altcorrection1", - "page": "10", - "hitsPerPage": "10" + "page": 10, + "hitsPerPage": 10 } } }