From a345a79b87d21ebd5aa7c3abab2e3837a0ab71b3 Mon Sep 17 00:00:00 2001 From: Morgan Leroi Date: Mon, 22 Jan 2024 16:59:23 +0100 Subject: [PATCH 01/16] change `searchSynonyms` spec --- specs/search/paths/synonyms/searchSynonyms.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 From c2a0a3b1b43e02621a924811a3cfaf1eafcfdcc3 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 14:55:33 +0100 Subject: [PATCH 02/16] fix: python --- templates/python/api.mustache | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/python/api.mustache b/templates/python/api.mustache index d06fcddc3d..8e0b1f9f98 100644 --- a/templates/python/api.mustache +++ b/templates/python/api.mustache @@ -5,6 +5,10 @@ from algoliasearch.{{packageName}}.models.{{#lambda.snakecase}}{{{.}}}{{/lambda.snakecase}} import {{{.}}} {{/imports}}{{/operation}}{{/operations}} +{{#isSearchClient}} +from algoliasearch.{{packageName}}.models.synonym_type import SynonymType +{{/isSearchClient}} + {{#operations}} class {{classname}}: From 1505d26b142813a1785161eb92cf43dcf0a6507b Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:01:18 +0100 Subject: [PATCH 03/16] fix: java --- templates/java/api_helpers.mustache | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/java/api_helpers.mustache b/templates/java/api_helpers.mustache index 63a204355f..592f371e60 100644 --- a/templates/java/api_helpers.mustache +++ b/templates/java/api_helpers.mustache @@ -248,17 +248,16 @@ 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; return AlgoliaIterableHelper.createIterable( () -> { - SearchSynonymsResponse response = this.searchSynonyms(indexName, type, currentPage.value, hitsPerPage, params, requestOptions); + SearchSynonymsResponse response = this.searchSynonyms(indexName, currentPage.value, hitsPerPage, params, requestOptions); currentPage.value = response.getNbHits() < hitsPerPage ? null : currentPage.value + 1; return response.getHits().iterator(); }, @@ -270,11 +269,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 +282,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); } /** From 64de7a002a354cf037fb17410de00e843769e755 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:04:33 +0100 Subject: [PATCH 04/16] fix: python --- templates/python/search_helpers.mustache | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/templates/python/search_helpers.mustache b/templates/python/search_helpers.mustache index ee7b4ae00a..4d0f63a5a8 100644 --- a/templates/python/search_helpers.mustache +++ b/templates/python/search_helpers.mustache @@ -136,7 +136,6 @@ 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(), @@ -150,7 +149,6 @@ 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, @@ -160,4 +158,4 @@ func=_func, validate=lambda _resp: _resp.nb_hits < hits_per_page, aggregator=aggregator, - ) + ) \ No newline at end of file From 02ebc496bf484e5d586d0038c781289fb461747b Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:06:55 +0100 Subject: [PATCH 05/16] fix: python again --- templates/python/api.mustache | 4 ---- 1 file changed, 4 deletions(-) diff --git a/templates/python/api.mustache b/templates/python/api.mustache index 8e0b1f9f98..d06fcddc3d 100644 --- a/templates/python/api.mustache +++ b/templates/python/api.mustache @@ -5,10 +5,6 @@ from algoliasearch.{{packageName}}.models.{{#lambda.snakecase}}{{{.}}}{{/lambda.snakecase}} import {{{.}}} {{/imports}}{{/operation}}{{/operations}} -{{#isSearchClient}} -from algoliasearch.{{packageName}}.models.synonym_type import SynonymType -{{/isSearchClient}} - {{#operations}} class {{classname}}: From ef1eed7cf17ad6463865a9b0b0f9bfa38eeda321 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:08:30 +0100 Subject: [PATCH 06/16] fix: cts --- tests/CTS/requests/search/searchSynonyms.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CTS/requests/search/searchSynonyms.json b/tests/CTS/requests/search/searchSynonyms.json index a9c5575772..a12c633780 100644 --- a/tests/CTS/requests/search/searchSynonyms.json +++ b/tests/CTS/requests/search/searchSynonyms.json @@ -13,11 +13,11 @@ "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": { From bc65913ed2d7b20c97a9904713c9b5f1a2fc9d9c Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:24:32 +0100 Subject: [PATCH 07/16] fix: java helper --- templates/java/api_helpers.mustache | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/java/api_helpers.mustache b/templates/java/api_helpers.mustache index 592f371e60..552c46ffc3 100644 --- a/templates/java/api_helpers.mustache +++ b/templates/java/api_helpers.mustache @@ -253,12 +253,14 @@ public Iterable browseObjects(String indexName, BrowseParamsObject params */ 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, 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 From 00fd196e4ad286606834f1a1c84690a26165eeef Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:26:52 +0100 Subject: [PATCH 08/16] fix: python helper --- templates/python/search_helpers.mustache | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/templates/python/search_helpers.mustache b/templates/python/search_helpers.mustache index 4d0f63a5a8..71d20a3e9a 100644 --- a/templates/python/search_helpers.mustache +++ b/templates/python/search_helpers.mustache @@ -136,26 +136,25 @@ self, index_name: str, aggregator: Optional[Callable[[SearchSynonymsResponse], 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, - 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 From bc56e5217ec479c9db07d08272a8098683f382c6 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:34:38 +0100 Subject: [PATCH 09/16] fix: cts --- tests/CTS/requests/search/searchSynonyms.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/CTS/requests/search/searchSynonyms.json b/tests/CTS/requests/search/searchSynonyms.json index a12c633780..0aa9dd4a67 100644 --- a/tests/CTS/requests/search/searchSynonyms.json +++ b/tests/CTS/requests/search/searchSynonyms.json @@ -24,9 +24,7 @@ "path": "/1/indexes/indexName/synonyms/search", "method": "POST", "body": { - "query": "myQuery" - }, - "queryParameters": { + "query": "myQuery", "type": "altcorrection1", "page": "10", "hitsPerPage": "10" From b11da2ba563a6433614f3d07c80eeca50bbf6b4c Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:43:57 +0100 Subject: [PATCH 10/16] fix: cts part 12 --- tests/CTS/requests/search/searchSynonyms.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CTS/requests/search/searchSynonyms.json b/tests/CTS/requests/search/searchSynonyms.json index 0aa9dd4a67..6cca27be1e 100644 --- a/tests/CTS/requests/search/searchSynonyms.json +++ b/tests/CTS/requests/search/searchSynonyms.json @@ -26,8 +26,8 @@ "body": { "query": "myQuery", "type": "altcorrection1", - "page": "10", - "hitsPerPage": "10" + "page": 10, + "hitsPerPage": 10 } } } From e2491a0ca0602526b3e13967e5eb573e4d9f9918 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:46:33 +0100 Subject: [PATCH 11/16] fix: javascript --- .../javascript/clients/client/api/helpers.mustache | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/javascript/clients/client/api/helpers.mustache b/templates/javascript/clients/client/api/helpers.mustache index 0c4ffad829..b43e9b4676 100644 --- a/templates/javascript/clients/client/api/helpers.mustache +++ b/templates/javascript/clients/client/api/helpers.mustache @@ -216,11 +216,13 @@ browseSynonyms( func: (previousResponse) => { return this.searchSynonyms( { - ...params, indexName, - page: previousResponse - ? previousResponse.page + 1 - : browseSynonymsOptions.page || 0, + searchSynonymsParams: { + ...params.searchSynonymsParams, + page: previousResponse + ? previousResponse.page + 1 + : params.searchSynonymsParams?.page || 0, + } }, requestOptions ); From a2752ca52f23e286058df99a8169407337a4c2cb Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 15:57:54 +0100 Subject: [PATCH 12/16] fix: javascript part 88 --- .../clients/client/api/helpers.mustache | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/templates/javascript/clients/client/api/helpers.mustache b/templates/javascript/clients/client/api/helpers.mustache index b43e9b4676..29aec6d3ef 100644 --- a/templates/javascript/clients/client/api/helpers.mustache +++ b/templates/javascript/clients/client/api/helpers.mustache @@ -196,20 +196,21 @@ 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 = { + const params: SearchSynonymsParams = { + page: 0, + ...searchSynonymsParams, hitsPerPage: 1000, - ...browseSynonymsOptions, }; return createIterablePromise({ @@ -218,11 +219,11 @@ browseSynonyms( { indexName, searchSynonymsParams: { - ...params.searchSynonymsParams, + ...params, page: previousResponse ? previousResponse.page + 1 - : params.searchSynonymsParams?.page || 0, - } + : params.page, + }, }, requestOptions ); From 18de1b4ac50db3a24fcb57c6e799b31171bcc429 Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 16:07:33 +0100 Subject: [PATCH 13/16] chore: stp c'est que du cache --- .github/.cache_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.cache_version b/.github/.cache_version index b0f3d96f87..66c4c2263e 100644 --- a/.github/.cache_version +++ b/.github/.cache_version @@ -1 +1 @@ -1.0.8 +1.0.9 From 2a2cd9c221b28bd700b41efb0eb692befaba5e8a Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 16:16:54 +0100 Subject: [PATCH 14/16] fix: javascript part 112 From 25c5654ec0b1d712508b0a7df03afa62ad15a0ea Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 16:17:22 +0100 Subject: [PATCH 15/16] fix: javascript part 113 --- templates/javascript/clients/client/api/helpers.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/javascript/clients/client/api/helpers.mustache b/templates/javascript/clients/client/api/helpers.mustache index 29aec6d3ef..7949b4cca0 100644 --- a/templates/javascript/clients/client/api/helpers.mustache +++ b/templates/javascript/clients/client/api/helpers.mustache @@ -207,7 +207,7 @@ browseSynonyms( }: BrowseOptions & SearchSynonymsProps, requestOptions?: RequestOptions ): Promise { - const params: SearchSynonymsParams = { + const params = { page: 0, ...searchSynonymsParams, hitsPerPage: 1000, From 5de0b6c3513f1ad1e11b9e0fcac0c63ea5fd7a9f Mon Sep 17 00:00:00 2001 From: shortcuts Date: Tue, 23 Jan 2024 16:33:41 +0100 Subject: [PATCH 16/16] fix: cache again --- .github/.cache_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.cache_version b/.github/.cache_version index 66c4c2263e..59e9e60491 100644 --- a/.github/.cache_version +++ b/.github/.cache_version @@ -1 +1 @@ -1.0.9 +1.0.11