From 6361b6026a65d66c5eb1a243516fb31acd6be82e Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 19 May 2022 13:36:38 +0200 Subject: [PATCH 1/8] style(specs): add out-of-line-one-of rule (and allOf and anyOf) APIC-418 (#512) --- .eslintrc.js | 6 +- eslint/src/index.ts | 7 ++- eslint/src/rules/outOfLineEnum.ts | 44 -------------- eslint/src/rules/outOfLineRule.ts | 57 +++++++++++++++++++ .../{endWithDot.ts => endWithDot.test.ts} | 4 +- ...LineEnum.test.ts => outOfLineRule.test.ts} | 5 +- scripts/ci/githubActions/setRunVariables.ts | 2 +- website/docs/automation/add-new-language.md | 2 + 8 files changed, 75 insertions(+), 52 deletions(-) delete mode 100644 eslint/src/rules/outOfLineEnum.ts create mode 100644 eslint/src/rules/outOfLineRule.ts rename eslint/tests/{endWithDot.ts => endWithDot.test.ts} (91%) rename eslint/tests/{outOfLineEnum.test.ts => outOfLineRule.test.ts} (79%) diff --git a/.eslintrc.js b/.eslintrc.js index 1dd164239e..017c5af1d4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,5 @@ module.exports = { - ignorePatterns: ['.eslintrc.js', '**/node_modules', '**/build', '**/dist', '**/target', '**/.yarn'], + ignorePatterns: ['.eslintrc.js', '**/node_modules', '**/build', '**/dist', '**/target', '**/.yarn', 'specs/bundled/*.doc.yml'], overrides: [ { @@ -51,6 +51,10 @@ module.exports = { files: ['!specs/bundled/*.yml'], rules: { "automation-custom/out-of-line-enum": "error", + "automation-custom/out-of-line-one-of": "error", + "automation-custom/out-of-line-all-of": "error", + "automation-custom/out-of-line-any-of": "error", + } } ] diff --git a/eslint/src/index.ts b/eslint/src/index.ts index 8a3bdffe4a..57e777f251 100644 --- a/eslint/src/index.ts +++ b/eslint/src/index.ts @@ -1,10 +1,13 @@ import { endWithDot } from './rules/endWithDot'; -import { outOfLineEnum } from './rules/outOfLineEnum'; +import { createOutOfLineRule } from './rules/outOfLineRule'; import { singleQuoteRef } from './rules/singleQuoteRef'; const rules = { 'end-with-dot': endWithDot, - 'out-of-line-enum': outOfLineEnum, + 'out-of-line-enum': createOutOfLineRule({ property: 'enum' }), + 'out-of-line-one-of': createOutOfLineRule({ property: 'oneOf' }), + 'out-of-line-all-of': createOutOfLineRule({ property: 'allOf' }), + 'out-of-line-any-of': createOutOfLineRule({ property: 'anyOf' }), 'single-quote-ref': singleQuoteRef, }; diff --git a/eslint/src/rules/outOfLineEnum.ts b/eslint/src/rules/outOfLineEnum.ts deleted file mode 100644 index ea7c64a50a..0000000000 --- a/eslint/src/rules/outOfLineEnum.ts +++ /dev/null @@ -1,44 +0,0 @@ -import type { Rule } from 'eslint'; - -import { isPairWithKey } from '../utils'; - -export const outOfLineEnum: Rule.RuleModule = { - meta: { - docs: { - description: 'enum must be out of line', - }, - messages: { - enumNotOutOfLine: 'enum is not out of line', - }, - }, - create(context) { - if (!context.parserServices.isYAML) { - return {}; - } - - return { - YAMLPair(node): void { - if (!isPairWithKey(node, 'enum')) { - return; - } - // parent is mapping, and parent is real parent that must be to the far left - if (node.parent.parent.loc.start.column === 0) { - return; - } - if ( - isPairWithKey( - node.parent.parent.parent.parent?.parent?.parent?.parent ?? null, - 'servers' - ) - ) { - // accept out of line enum if in servers - return; - } - context.report({ - node: node.parent.parent as any, - messageId: 'enumNotOutOfLine', - }); - }, - }; - }, -}; diff --git a/eslint/src/rules/outOfLineRule.ts b/eslint/src/rules/outOfLineRule.ts new file mode 100644 index 0000000000..099423cd47 --- /dev/null +++ b/eslint/src/rules/outOfLineRule.ts @@ -0,0 +1,57 @@ +import type { Rule } from 'eslint'; + +import { isPairWithKey } from '../utils'; + +export function createOutOfLineRule({ + property, + description = `${property} must be out of line, not nested inside properties`, + messageId = `${property}NotOutOfLine`, + message = `${property} must be out of line`, +}: { + property: string; + description?: string; + messageId?: string; + message?: string; +}): Rule.RuleModule { + const rule: Rule.RuleModule = { + meta: { + docs: { + description, + }, + messages: { + [messageId]: message, + }, + }, + create(context) { + if (!context.parserServices.isYAML) { + return {}; + } + + return { + YAMLPair(node): void { + if (!isPairWithKey(node, property)) { + return; + } + // parent is mapping, and parent is real parent that must be to the far left + if (node.parent.parent.loc.start.column === 0) { + return; + } + // accept anything in servers + if ( + isPairWithKey( + node.parent.parent.parent.parent?.parent?.parent?.parent ?? null, + 'servers' + ) + ) { + return; + } + context.report({ + node: node.parent.parent as any, + messageId, + }); + }, + }; + }, + }; + return rule; +} diff --git a/eslint/tests/endWithDot.ts b/eslint/tests/endWithDot.test.ts similarity index 91% rename from eslint/tests/endWithDot.ts rename to eslint/tests/endWithDot.test.ts index a4c0aa77aa..443f3105da 100644 --- a/eslint/tests/endWithDot.ts +++ b/eslint/tests/endWithDot.test.ts @@ -38,7 +38,7 @@ responses: simple: description: a number `, - errors: [{ messageId: 'descriptionNoDot' }], + errors: [{ messageId: 'endWithDot' }], output: ` simple: description: a number. @@ -51,7 +51,7 @@ multi: Multiline comment on description `, - errors: [{ messageId: 'descriptionNoDot' }], + errors: [{ messageId: 'endWithDot' }], output: ` multi: description: > diff --git a/eslint/tests/outOfLineEnum.test.ts b/eslint/tests/outOfLineRule.test.ts similarity index 79% rename from eslint/tests/outOfLineEnum.test.ts rename to eslint/tests/outOfLineRule.test.ts index 22db0e3ef1..9463b413d6 100644 --- a/eslint/tests/outOfLineEnum.test.ts +++ b/eslint/tests/outOfLineRule.test.ts @@ -1,12 +1,13 @@ import { RuleTester } from 'eslint'; -import { outOfLineEnum } from '../src/rules/outOfLineEnum'; +import { createOutOfLineRule } from '../src/rules/outOfLineRule'; const ruleTester = new RuleTester({ parser: require.resolve('yaml-eslint-parser'), }); -ruleTester.run('out-of-line-enum', outOfLineEnum, { +// this test is enough for oneOf, allOf, anyOf, as they use the same rule. +ruleTester.run('out-of-line-enum', createOutOfLineRule({ property: 'enum' }), { valid: [ ` simple: diff --git a/scripts/ci/githubActions/setRunVariables.ts b/scripts/ci/githubActions/setRunVariables.ts index ea7760041a..784a20ba5c 100644 --- a/scripts/ci/githubActions/setRunVariables.ts +++ b/scripts/ci/githubActions/setRunVariables.ts @@ -23,7 +23,7 @@ export const COMMON_DEPENDENCIES = { '.github/workflows', '.github/.cache_version', ], - SCRIPTS_CHANGED: ['scripts'], + SCRIPTS_CHANGED: ['scripts', 'eslint'], COMMON_SPECS_CHANGED: ['specs/common'], }; diff --git a/website/docs/automation/add-new-language.md b/website/docs/automation/add-new-language.md index f49ba1c275..b6aeb9f385 100644 --- a/website/docs/automation/add-new-language.md +++ b/website/docs/automation/add-new-language.md @@ -109,6 +109,8 @@ Algolia for Java (5.0.0); Search (5.0.0); JVM (11.0.14); experimental You can take a look at the Java implementation [here](https://github.com/algolia/api-clients-automation/pull/347). +The function must be named `addAlgoliaAgent` because of JavaScript exception that doesn't allow custom `User-Agent` in the header, and must use `x-algolia-agent`. + ### Dependencies You can use any dependency you want to create the client, it can be Json parser or HTTP client, but it's important to never expose those dependencies through the client, meaning: From 3b3d7067ef32fbd36cae4ff4bf2ffbc2ae488aac Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Thu, 19 May 2022 14:00:20 +0200 Subject: [PATCH 2/8] fix(specs): correct mistakes (#509) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte --- .../src/transporter/createTransporter.ts | 4 ++-- .../client-common/src/types/Transporter.ts | 18 +++++++++--------- specs/abtesting/common/parameters.yml | 2 +- specs/common/responses/Success.yml | 2 +- .../common/schemas/QuerySuggestionsIndex.yml | 6 +++--- specs/query-suggestions/paths/qsConfig.yml | 2 +- specs/search/common/schemas/SearchResponse.yml | 2 +- .../common/schemas/listIndicesResponse.yml | 4 ++-- specs/search/paths/advanced/getLogs.yml | 4 ++-- .../dictionaries/batchDictionaryEntries.yml | 2 +- .../paths/dictionaries/dictionarySettings.yml | 4 ++-- .../dictionaries/getDictionaryLanguages.yml | 2 +- .../dictionaries/searchDictionaryEntries.yml | 2 +- .../paths/manage_indices/operationIndex.yml | 2 +- specs/search/spec.yml | 6 +++--- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts b/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts index f322013ee5..6193274a49 100644 --- a/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts +++ b/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts @@ -292,7 +292,7 @@ export function createTransporter({ const cacheable = Boolean(requestOptions.cacheable || request.cacheable); /** - * If is not "cacheable", we immediatly trigger the retryable request, no + * If is not "cacheable", we immediately trigger the retryable request, no * need to check cache implementations. */ if (cacheable !== true) { @@ -315,7 +315,7 @@ export function createTransporter({ /** * With the computed key, we first ask the responses cache - * implemention if this request was been resolved before. + * implementation if this request was been resolved before. */ return responsesCache.get( key, diff --git a/clients/algoliasearch-client-javascript/packages/client-common/src/types/Transporter.ts b/clients/algoliasearch-client-javascript/packages/client-common/src/types/Transporter.ts index 6a857c291f..2dc0f61da1 100644 --- a/clients/algoliasearch-client-javascript/packages/client-common/src/types/Transporter.ts +++ b/clients/algoliasearch-client-javascript/packages/client-common/src/types/Transporter.ts @@ -7,7 +7,7 @@ export type QueryParameters = Record; export type RequestOptions = { /** - * Custom timeout for the request. Note that, in normal situacions + * Custom timeout for the request. Note that, in normal situations * the given timeout will be applied. But the transporter layer may * increase this timeout if there is need for it. */ @@ -64,7 +64,7 @@ export type AlgoliaAgent = { value: string; /** - * Mutates the current user agent ading the given user agent options. + * Mutates the current user agent adding the given user agent options. */ add: (options: AlgoliaAgentOptions) => AlgoliaAgent; }; @@ -84,7 +84,7 @@ export type TransporterOptions = { /** * The underlying requester used. Should differ - * depending of the enviroment where the client + * depending of the environment where the client * will be used. */ requester: Requester; @@ -92,7 +92,7 @@ export type TransporterOptions = { /** * The cache of the requests. When requests are * `cacheable`, the returned promised persists - * in this cache to shared in similar resquests + * in this cache to shared in similar requests * before being resolved. */ requestsCache: Cache; @@ -100,7 +100,7 @@ export type TransporterOptions = { /** * The cache of the responses. When requests are * `cacheable`, the returned responses persists - * in this cache to shared in similar resquests. + * in this cache to shared in similar requests. */ responsesCache: Cache; @@ -145,7 +145,7 @@ export type Transporter = { /** * The underlying requester used. Should differ - * depending of the enviroment where the client + * depending of the environment where the client * will be used. */ requester: Requester; @@ -153,7 +153,7 @@ export type Transporter = { /** * The cache of the requests. When requests are * `cacheable`, the returned promised persists - * in this cache to shared in similar resquests + * in this cache to shared in similar requests * before being resolved. */ requestsCache: Cache; @@ -161,7 +161,7 @@ export type Transporter = { /** * The cache of the responses. When requests are * `cacheable`, the returned responses persists - * in this cache to shared in similar resquests. + * in this cache to shared in similar requests. */ responsesCache: Cache; @@ -194,7 +194,7 @@ export type Transporter = { /** * Performs a request. - * The `baseRequest` and `baseRequestOptions` will be merged accordignly. + * The `baseRequest` and `baseRequestOptions` will be merged accordingly. */ request: ( baseRequest: Request, diff --git a/specs/abtesting/common/parameters.yml b/specs/abtesting/common/parameters.yml index 8d8728a591..46baae2911 100644 --- a/specs/abtesting/common/parameters.yml +++ b/specs/abtesting/common/parameters.yml @@ -34,4 +34,4 @@ description: trafficPercentage: type: integer - description: The traffic perfecentage for the A/B test. + description: The traffic percentage for the A/B test. diff --git a/specs/common/responses/Success.yml b/specs/common/responses/Success.yml index 06d5bbde78..53f53ef3b3 100644 --- a/specs/common/responses/Success.yml +++ b/specs/common/responses/Success.yml @@ -3,7 +3,7 @@ content: application/json: schema: type: object - title: SucessResponse + title: SuccessResponse additionalProperties: false required: - status diff --git a/specs/query-suggestions/common/schemas/QuerySuggestionsIndex.yml b/specs/query-suggestions/common/schemas/QuerySuggestionsIndex.yml index c5751d173c..01f1c9d6b2 100644 --- a/specs/query-suggestions/common/schemas/QuerySuggestionsIndex.yml +++ b/specs/query-suggestions/common/schemas/QuerySuggestionsIndex.yml @@ -27,12 +27,12 @@ SourceIndicesWithReplicas: type: array description: List of source indices used to generate a Query Suggestions index. items: - $ref: '#/SourceIndiceWithReplicas' + $ref: '#/SourceIndexWithReplicas' -SourceIndiceWithReplicas: +SourceIndexWithReplicas: type: object additionalProperties: false - description: Source indice with replicas used to generate a Query Suggestions index. + description: Source index with replicas used to generate a Query Suggestions index. required: - replicas - indexName diff --git a/specs/query-suggestions/paths/qsConfig.yml b/specs/query-suggestions/paths/qsConfig.yml index bdaa1cf351..c6b112904b 100644 --- a/specs/query-suggestions/paths/qsConfig.yml +++ b/specs/query-suggestions/paths/qsConfig.yml @@ -54,7 +54,7 @@ delete: description: > Delete a configuration of a Query Suggestion's index. - By deleting a configuraton, you stop all updates to the underlying query suggestion index. + By deleting a configuration, you stop all updates to the underlying query suggestion index. Note that when doing this, the underlying index does not change - existing suggestions remain untouched. parameters: diff --git a/specs/search/common/schemas/SearchResponse.yml b/specs/search/common/schemas/SearchResponse.yml index b832c1aaa2..2ff61ba1f8 100644 --- a/specs/search/common/schemas/SearchResponse.yml +++ b/specs/search/common/schemas/SearchResponse.yml @@ -63,7 +63,7 @@ baseSearchResponse: description: Indicate if the nbHits count was exhaustive or approximate. exhaustiveTypo: type: boolean - description: Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled). + description: Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). facets: type: object additionalProperties: diff --git a/specs/search/common/schemas/listIndicesResponse.yml b/specs/search/common/schemas/listIndicesResponse.yml index a53d47b911..43f97b80ef 100644 --- a/specs/search/common/schemas/listIndicesResponse.yml +++ b/specs/search/common/schemas/listIndicesResponse.yml @@ -6,13 +6,13 @@ listIndicesResponse: type: array description: List of the fetched indices. items: - $ref: '#/indice' + $ref: '#/fetchedIndex' nbPages: type: integer description: Number of pages. example: 100 -indice: +fetchedIndex: type: object additionalProperties: false properties: diff --git a/specs/search/paths/advanced/getLogs.yml b/specs/search/paths/advanced/getLogs.yml index 55b6b5f3ad..2abf611b78 100644 --- a/specs/search/paths/advanced/getLogs.yml +++ b/specs/search/paths/advanced/getLogs.yml @@ -51,7 +51,7 @@ get: description: Timestamp in ISO-8601 format. method: type: string - description: HTTP method of the perfomed request. + description: HTTP method of the performed request. answer_code: type: string description: HTTP response code. @@ -66,7 +66,7 @@ get: description: Request URL. ip: type: string - description: IP of the client which perfomed the request. + description: IP of the client which performed the request. query_headers: type: string description: Request Headers (API Key is obfuscated). diff --git a/specs/search/paths/dictionaries/batchDictionaryEntries.yml b/specs/search/paths/dictionaries/batchDictionaryEntries.yml index 02814d06c4..a3c35b98ed 100644 --- a/specs/search/paths/dictionaries/batchDictionaryEntries.yml +++ b/specs/search/paths/dictionaries/batchDictionaryEntries.yml @@ -1,6 +1,6 @@ post: tags: - - Dictionnaries + - Dictionaries operationId: batchDictionaryEntries description: Send a batch of dictionary entries. summary: Batch dictionary entries. diff --git a/specs/search/paths/dictionaries/dictionarySettings.yml b/specs/search/paths/dictionaries/dictionarySettings.yml index 516d4f0e4e..e995931916 100644 --- a/specs/search/paths/dictionaries/dictionarySettings.yml +++ b/specs/search/paths/dictionaries/dictionarySettings.yml @@ -1,6 +1,6 @@ get: tags: - - Dictionnaries + - Dictionaries operationId: getDictionarySettings description: Retrieve dictionaries settings. The API stores languages whose standard entries are disabled. Fetch settings does not return false values. summary: Retrieve dictionaries settings. @@ -29,7 +29,7 @@ get: put: tags: - - Dictionnaries + - Dictionaries operationId: setDictionarySettings description: Set dictionaries settings. summary: Set dictionaries settings. diff --git a/specs/search/paths/dictionaries/getDictionaryLanguages.yml b/specs/search/paths/dictionaries/getDictionaryLanguages.yml index 215569241e..4d8abb6e30 100644 --- a/specs/search/paths/dictionaries/getDictionaryLanguages.yml +++ b/specs/search/paths/dictionaries/getDictionaryLanguages.yml @@ -1,6 +1,6 @@ get: tags: - - Dictionnaries + - Dictionaries operationId: getDictionaryLanguages description: List dictionaries supported per language. summary: List available languages. diff --git a/specs/search/paths/dictionaries/searchDictionaryEntries.yml b/specs/search/paths/dictionaries/searchDictionaryEntries.yml index f941d30b8a..725cf76942 100644 --- a/specs/search/paths/dictionaries/searchDictionaryEntries.yml +++ b/specs/search/paths/dictionaries/searchDictionaryEntries.yml @@ -1,6 +1,6 @@ post: tags: - - Dictionnaries + - Dictionaries operationId: searchDictionaryEntries description: Search the dictionary entries. summary: Search a dictionary entries. diff --git a/specs/search/paths/manage_indices/operationIndex.yml b/specs/search/paths/manage_indices/operationIndex.yml index 481e6c771d..638897ad19 100644 --- a/specs/search/paths/manage_indices/operationIndex.yml +++ b/specs/search/paths/manage_indices/operationIndex.yml @@ -3,7 +3,7 @@ post: - Indices operationId: operationIndex summary: Copy/move index. - description: Peforms a copy or a move operation on a index. + description: Performs a copy or a move operation on a index. parameters: - $ref: '../../../common/parameters.yml#/IndexName' requestBody: diff --git a/specs/search/spec.yml b/specs/search/spec.yml index 1656fbd377..7de5efc04d 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -40,8 +40,8 @@ tags: description: Manage your Api Keys. - name: Clusters description: Clusters operations. - - name: Dictionnaries - description: Dictionnaries operations. + - name: Dictionaries + description: Dictionaries operations. - name: Indices description: Manage indices. - name: Records @@ -68,7 +68,7 @@ x-tagGroups: tags: - Rules - Synonyms - - Dictionnaries + - Dictionaries - name: Others tags: - Api Keys From 2d9c15744b086391b23b5673bc624473c106c5b5 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Thu, 19 May 2022 12:12:12 +0000 Subject: [PATCH 3/8] chore: generated code for commit 3b3d7067ef32fbd36cae4ff4bf2ffbc2ae488aac. [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Haroen Viaene Co-authored-by: Clément Vannicatte --- .../algolia/api/QuerySuggestionsClient.java | 40 +- .../java/com/algolia/api/SearchClient.java | 4 +- .../model/abtesting/AbTestsVariant.java | 2 +- .../abtesting/AbTestsVariantSearchParams.java | 2 +- .../com/algolia/model/abtesting/Variant.java | 2 +- .../QuerySuggestionsIndex.java | 8 +- .../SourceIndexWithReplicas.java | 250 ++++++++ .../querySuggestions/SuccessResponse.java | 84 +++ .../model/recommend/BaseSearchResponse.java | 2 +- .../recommend/RecommendationsResponse.java | 2 +- .../model/search/BaseSearchResponse.java | 2 +- .../algolia/model/search/BrowseResponse.java | 2 +- .../algolia/model/search/FetchedIndex.java | 306 ++++++++++ .../model/search/GetLogsResponseLogs.java | 4 +- .../model/search/ListIndicesResponse.java | 8 +- .../algolia/model/search/SearchResponse.java | 2 +- .../model/baseSearchResponse.ts | 2 +- .../algoliasearch-lite/model/fetchedIndex.ts | 46 ++ .../algoliasearch-lite/model/index.ts | 2 +- .../model/listIndicesResponse.ts | 4 +- .../client-abtesting/model/abTestsVariant.ts | 2 +- .../client-abtesting/model/variant.ts | 2 +- .../client-query-suggestions/model/index.ts | 4 +- .../model/querySuggestionsIndex.ts | 4 +- .../model/sourceIndexWithReplicas.ts | 39 ++ .../model/successResponse.ts | 10 + .../src/querySuggestionsClient.ts | 10 +- .../client-search/model/baseSearchResponse.ts | 2 +- .../client-search/model/fetchedIndex.ts | 46 ++ .../model/getLogsResponseLogs.ts | 4 +- .../packages/client-search/model/index.ts | 2 +- .../model/listIndicesResponse.ts | 4 +- .../client-search/src/searchClient.ts | 2 +- .../recommend/model/baseSearchResponse.ts | 2 +- .../lib/Api/QuerySuggestionsClient.php | 6 +- .../lib/Model/Abtesting/AbTestsVariant.php | 2 +- .../Abtesting/AbTestsVariantSearchParams.php | 2 +- .../lib/Model/Abtesting/AddABTestsVariant.php | 2 +- .../lib/Model/Abtesting/Variant.php | 2 +- .../QuerySuggestionsIndex.php | 6 +- .../SourceIndexWithReplicas.php | 477 +++++++++++++++ .../QuerySuggestions/SuccessResponse.php | 253 ++++++++ .../Model/Recommend/BaseSearchResponse.php | 2 +- .../Recommend/RecommendationsResponse.php | 2 +- .../lib/Model/Search/BaseSearchResponse.php | 2 +- .../lib/Model/Search/BrowseResponse.php | 2 +- .../lib/Model/Search/FetchedIndex.php | 569 ++++++++++++++++++ .../lib/Model/Search/GetLogsResponseLogs.php | 4 +- .../lib/Model/Search/ListIndicesResponse.php | 6 +- .../lib/Model/Search/SearchResponse.php | 2 +- specs/bundled/abtesting.yml | 2 +- specs/bundled/algoliasearch-lite.yml | 12 +- specs/bundled/query-suggestions.yml | 12 +- specs/bundled/recommend.yml | 2 +- specs/bundled/search.yml | 18 +- 55 files changed, 2186 insertions(+), 106 deletions(-) create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SourceIndexWithReplicas.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SuccessResponse.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/FetchedIndex.java create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/fetchedIndex.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndexWithReplicas.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/successResponse.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/fetchedIndex.ts create mode 100644 clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndexWithReplicas.php create mode 100644 clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SuccessResponse.php create mode 100644 clients/algoliasearch-client-php/lib/Model/Search/FetchedIndex.php diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/QuerySuggestionsClient.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/QuerySuggestionsClient.java index f416e7de81..8ce50dc34c 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/QuerySuggestionsClient.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/QuerySuggestionsClient.java @@ -73,11 +73,11 @@ private static List getDefaultHosts(String region) { * @param querySuggestionsIndexWithIndexParam (required) * @param requestOptions The requestOptions to send along with the query, they will be merged with * the transporter requestOptions. - * @return SucessResponse + * @return SuccessResponse * @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot * deserialize the response body */ - public SucessResponse createConfig( + public SuccessResponse createConfig( QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam, RequestOptions requestOptions ) throws AlgoliaRuntimeException { @@ -86,7 +86,7 @@ public SucessResponse createConfig( ); } - public SucessResponse createConfig( + public SuccessResponse createConfig( QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam ) throws AlgoliaRuntimeException { return this.createConfig(querySuggestionsIndexWithIndexParam, null); @@ -103,7 +103,7 @@ public SucessResponse createConfig( * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request * body object */ - public CompletableFuture createConfigAsync( + public CompletableFuture createConfigAsync( QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam, RequestOptions requestOptions ) throws AlgoliaRuntimeException { @@ -131,11 +131,11 @@ public CompletableFuture createConfigAsync( headers, requestOptions ); - Type returnType = new TypeToken() {}.getType(); + Type returnType = new TypeToken() {}.getType(); return this.executeAsync(call, returnType); } - public CompletableFuture createConfigAsync( + public CompletableFuture createConfigAsync( QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam ) throws AlgoliaRuntimeException { return this.createConfigAsync(querySuggestionsIndexWithIndexParam, null); @@ -248,32 +248,32 @@ public CompletableFuture delAsync(String path) } /** - * Delete a configuration of a Query Suggestion's index. By deleting a configuraton, you stop all + * Delete a configuration of a Query Suggestion's index. By deleting a configuration, you stop all * updates to the underlying query suggestion index. Note that when doing this, the underlying * index does not change - existing suggestions remain untouched. * * @param indexName The index in which to perform the request. (required) * @param requestOptions The requestOptions to send along with the query, they will be merged with * the transporter requestOptions. - * @return SucessResponse + * @return SuccessResponse * @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot * deserialize the response body */ - public SucessResponse deleteConfig( + public SuccessResponse deleteConfig( String indexName, RequestOptions requestOptions ) throws AlgoliaRuntimeException { return LaunderThrowable.await(deleteConfigAsync(indexName, requestOptions)); } - public SucessResponse deleteConfig(String indexName) + public SuccessResponse deleteConfig(String indexName) throws AlgoliaRuntimeException { return this.deleteConfig(indexName, null); } /** * (asynchronously) Delete a configuration of a Query Suggestion's index. By deleting a - * configuraton, you stop all updates to the underlying query suggestion index. Note that when + * configuration, you stop all updates to the underlying query suggestion index. Note that when * doing this, the underlying index does not change - existing suggestions remain untouched. * * @param indexName The index in which to perform the request. (required) @@ -283,7 +283,7 @@ public SucessResponse deleteConfig(String indexName) * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request * body object */ - public CompletableFuture deleteConfigAsync( + public CompletableFuture deleteConfigAsync( String indexName, RequestOptions requestOptions ) throws AlgoliaRuntimeException { @@ -314,11 +314,11 @@ public CompletableFuture deleteConfigAsync( headers, requestOptions ); - Type returnType = new TypeToken() {}.getType(); + Type returnType = new TypeToken() {}.getType(); return this.executeAsync(call, returnType); } - public CompletableFuture deleteConfigAsync(String indexName) + public CompletableFuture deleteConfigAsync(String indexName) throws AlgoliaRuntimeException { return this.deleteConfigAsync(indexName, null); } @@ -944,11 +944,11 @@ public CompletableFuture putAsync(String path) * @param querySuggestionsIndexParam (required) * @param requestOptions The requestOptions to send along with the query, they will be merged with * the transporter requestOptions. - * @return SucessResponse + * @return SuccessResponse * @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot * deserialize the response body */ - public SucessResponse updateConfig( + public SuccessResponse updateConfig( String indexName, QuerySuggestionsIndexParam querySuggestionsIndexParam, RequestOptions requestOptions @@ -958,7 +958,7 @@ public SucessResponse updateConfig( ); } - public SucessResponse updateConfig( + public SuccessResponse updateConfig( String indexName, QuerySuggestionsIndexParam querySuggestionsIndexParam ) throws AlgoliaRuntimeException { @@ -976,7 +976,7 @@ public SucessResponse updateConfig( * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request * body object */ - public CompletableFuture updateConfigAsync( + public CompletableFuture updateConfigAsync( String indexName, QuerySuggestionsIndexParam querySuggestionsIndexParam, RequestOptions requestOptions @@ -1015,11 +1015,11 @@ public CompletableFuture updateConfigAsync( headers, requestOptions ); - Type returnType = new TypeToken() {}.getType(); + Type returnType = new TypeToken() {}.getType(); return this.executeAsync(call, returnType); } - public CompletableFuture updateConfigAsync( + public CompletableFuture updateConfigAsync( String indexName, QuerySuggestionsIndexParam querySuggestionsIndexParam ) throws AlgoliaRuntimeException { diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java index 48edbf7b2f..d5d5e1affe 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java @@ -3791,7 +3791,7 @@ public CompletableFuture multipleQueriesAsync( } /** - * Peforms a copy or a move operation on a index. + * Performs a copy or a move operation on a index. * * @param indexName The index in which to perform the request. (required) * @param operationIndexParams (required) @@ -3819,7 +3819,7 @@ public UpdatedAtResponse operationIndex( } /** - * (asynchronously) Peforms a copy or a move operation on a index. + * (asynchronously) Performs a copy or a move operation on a index. * * @param indexName The index in which to perform the request. (required) * @param operationIndexParams (required) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariant.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariant.java index 85477d06df..d6ebff3dd6 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariant.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariant.java @@ -36,7 +36,7 @@ public AbTestsVariant setTrafficPercentage(Integer trafficPercentage) { } /** - * The traffic perfecentage for the A/B test. + * The traffic percentage for the A/B test. * * @return trafficPercentage */ diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariantSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariantSearchParams.java index 47703e1a91..8efcfd668a 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariantSearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/AbTestsVariantSearchParams.java @@ -41,7 +41,7 @@ public AbTestsVariantSearchParams setTrafficPercentage( } /** - * The traffic perfecentage for the A/B test. + * The traffic percentage for the A/B test. * * @return trafficPercentage */ diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/Variant.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/Variant.java index bbd035f488..d94a26698e 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/Variant.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/abtesting/Variant.java @@ -198,7 +198,7 @@ public Variant setTrafficPercentage(Integer trafficPercentage) { } /** - * The traffic perfecentage for the A/B test. + * The traffic percentage for the A/B test. * * @return trafficPercentage */ diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/QuerySuggestionsIndex.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/QuerySuggestionsIndex.java index 0116ef22b4..6531a40413 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/QuerySuggestionsIndex.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/QuerySuggestionsIndex.java @@ -12,7 +12,7 @@ public class QuerySuggestionsIndex { private String indexName; @SerializedName("sourceIndices") - private List sourceIndices = new ArrayList<>(); + private List sourceIndices = new ArrayList<>(); @SerializedName("languages") private List languages = new ArrayList<>(); @@ -36,14 +36,14 @@ public String getIndexName() { } public QuerySuggestionsIndex setSourceIndices( - List sourceIndices + List sourceIndices ) { this.sourceIndices = sourceIndices; return this; } public QuerySuggestionsIndex addSourceIndices( - SourceIndiceWithReplicas sourceIndicesItem + SourceIndexWithReplicas sourceIndicesItem ) { this.sourceIndices.add(sourceIndicesItem); return this; @@ -55,7 +55,7 @@ public QuerySuggestionsIndex addSourceIndices( * @return sourceIndices */ @javax.annotation.Nonnull - public List getSourceIndices() { + public List getSourceIndices() { return sourceIndices; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SourceIndexWithReplicas.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SourceIndexWithReplicas.java new file mode 100644 index 0000000000..8ffa2e998c --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SourceIndexWithReplicas.java @@ -0,0 +1,250 @@ +package com.algolia.model.querySuggestions; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Source index with replicas used to generate a Query Suggestions index. */ +public class SourceIndexWithReplicas { + + @SerializedName("replicas") + private Boolean replicas; + + @SerializedName("indexName") + private String indexName; + + @SerializedName("analyticsTags") + private List analyticsTags = new ArrayList<>(); + + @SerializedName("facets") + private List facets = new ArrayList<>(); + + @SerializedName("minHits") + private Integer minHits; + + @SerializedName("minLetters") + private Integer minLetters; + + @SerializedName("generate") + private List> generate = new ArrayList<>(); + + @SerializedName("external") + private List external = new ArrayList<>(); + + public SourceIndexWithReplicas setReplicas(Boolean replicas) { + this.replicas = replicas; + return this; + } + + /** + * true if the Query Suggestions index is a replicas. + * + * @return replicas + */ + @javax.annotation.Nonnull + public Boolean getReplicas() { + return replicas; + } + + public SourceIndexWithReplicas setIndexName(String indexName) { + this.indexName = indexName; + return this; + } + + /** + * Source index name. + * + * @return indexName + */ + @javax.annotation.Nonnull + public String getIndexName() { + return indexName; + } + + public SourceIndexWithReplicas setAnalyticsTags(List analyticsTags) { + this.analyticsTags = analyticsTags; + return this; + } + + public SourceIndexWithReplicas addAnalyticsTags(String analyticsTagsItem) { + this.analyticsTags.add(analyticsTagsItem); + return this; + } + + /** + * List of analytics tags to filter the popular searches per tag. + * + * @return analyticsTags + */ + @javax.annotation.Nonnull + public List getAnalyticsTags() { + return analyticsTags; + } + + public SourceIndexWithReplicas setFacets(List facets) { + this.facets = facets; + return this; + } + + public SourceIndexWithReplicas addFacets(Object facetsItem) { + this.facets.add(facetsItem); + return this; + } + + /** + * List of facets to define as categories for the query suggestions. + * + * @return facets + */ + @javax.annotation.Nonnull + public List getFacets() { + return facets; + } + + public SourceIndexWithReplicas setMinHits(Integer minHits) { + this.minHits = minHits; + return this; + } + + /** + * Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. + * + * @return minHits + */ + @javax.annotation.Nonnull + public Integer getMinHits() { + return minHits; + } + + public SourceIndexWithReplicas setMinLetters(Integer minLetters) { + this.minLetters = minLetters; + return this; + } + + /** + * Minimum number of required letters for a suggestion to remain. + * + * @return minLetters + */ + @javax.annotation.Nonnull + public Integer getMinLetters() { + return minLetters; + } + + public SourceIndexWithReplicas setGenerate(List> generate) { + this.generate = generate; + return this; + } + + public SourceIndexWithReplicas addGenerate(List generateItem) { + this.generate.add(generateItem); + return this; + } + + /** + * List of facet attributes used to generate Query Suggestions. The resulting suggestions are + * every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). + * + * @return generate + */ + @javax.annotation.Nonnull + public List> getGenerate() { + return generate; + } + + public SourceIndexWithReplicas setExternal( + List external + ) { + this.external = external; + return this; + } + + public SourceIndexWithReplicas addExternal(SourceIndexExternal externalItem) { + this.external.add(externalItem); + return this; + } + + /** + * List of external indices to use to generate custom Query Suggestions. + * + * @return external + */ + @javax.annotation.Nonnull + public List getExternal() { + return external; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SourceIndexWithReplicas sourceIndexWithReplicas = (SourceIndexWithReplicas) o; + return ( + Objects.equals(this.replicas, sourceIndexWithReplicas.replicas) && + Objects.equals(this.indexName, sourceIndexWithReplicas.indexName) && + Objects.equals( + this.analyticsTags, + sourceIndexWithReplicas.analyticsTags + ) && + Objects.equals(this.facets, sourceIndexWithReplicas.facets) && + Objects.equals(this.minHits, sourceIndexWithReplicas.minHits) && + Objects.equals(this.minLetters, sourceIndexWithReplicas.minLetters) && + Objects.equals(this.generate, sourceIndexWithReplicas.generate) && + Objects.equals(this.external, sourceIndexWithReplicas.external) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + replicas, + indexName, + analyticsTags, + facets, + minHits, + minLetters, + generate, + external + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SourceIndexWithReplicas {\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb + .append(" indexName: ") + .append(toIndentedString(indexName)) + .append("\n"); + sb + .append(" analyticsTags: ") + .append(toIndentedString(analyticsTags)) + .append("\n"); + sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); + sb.append(" minHits: ").append(toIndentedString(minHits)).append("\n"); + sb + .append(" minLetters: ") + .append(toIndentedString(minLetters)) + .append("\n"); + sb.append(" generate: ").append(toIndentedString(generate)).append("\n"); + sb.append(" external: ").append(toIndentedString(external)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SuccessResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SuccessResponse.java new file mode 100644 index 0000000000..d4406d6fe6 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/querySuggestions/SuccessResponse.java @@ -0,0 +1,84 @@ +package com.algolia.model.querySuggestions; + +import com.google.gson.annotations.SerializedName; +import java.util.Objects; + +/** SuccessResponse */ +public class SuccessResponse { + + @SerializedName("status") + private Integer status; + + @SerializedName("message") + private String message; + + public SuccessResponse setStatus(Integer status) { + this.status = status; + return this; + } + + /** + * The status code. + * + * @return status + */ + @javax.annotation.Nonnull + public Integer getStatus() { + return status; + } + + public SuccessResponse setMessage(String message) { + this.message = message; + return this; + } + + /** + * Message of the response. + * + * @return message + */ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SuccessResponse successResponse = (SuccessResponse) o; + return ( + Objects.equals(this.status, successResponse.status) && + Objects.equals(this.message, successResponse.message) + ); + } + + @Override + public int hashCode() { + return Objects.hash(status, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SuccessResponse {\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchResponse.java index a4b0a5f102..0f3c1cc2e9 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchResponse.java @@ -181,7 +181,7 @@ public BaseSearchResponse setExhaustiveTypo(Boolean exhaustiveTypo) { } /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when * typo-tolerance is enabled). * * @return exhaustiveTypo diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RecommendationsResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RecommendationsResponse.java index 514c885c98..db79ec3ea4 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RecommendationsResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RecommendationsResponse.java @@ -186,7 +186,7 @@ public RecommendationsResponse setExhaustiveTypo(Boolean exhaustiveTypo) { } /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when * typo-tolerance is enabled). * * @return exhaustiveTypo diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchResponse.java index a412593cea..21ac3d3387 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchResponse.java @@ -181,7 +181,7 @@ public BaseSearchResponse setExhaustiveTypo(Boolean exhaustiveTypo) { } /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when * typo-tolerance is enabled). * * @return exhaustiveTypo diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BrowseResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BrowseResponse.java index 90777e165a..7413bda8e3 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BrowseResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BrowseResponse.java @@ -189,7 +189,7 @@ public BrowseResponse setExhaustiveTypo(Boolean exhaustiveTypo) { } /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when * typo-tolerance is enabled). * * @return exhaustiveTypo diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/FetchedIndex.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/FetchedIndex.java new file mode 100644 index 0000000000..ed7229881f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/FetchedIndex.java @@ -0,0 +1,306 @@ +package com.algolia.model.search; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** FetchedIndex */ +public class FetchedIndex { + + @SerializedName("name") + private String name; + + @SerializedName("createdAt") + private String createdAt; + + @SerializedName("updatedAt") + private String updatedAt; + + @SerializedName("entries") + private Integer entries; + + @SerializedName("dataSize") + private Integer dataSize; + + @SerializedName("fileSize") + private Integer fileSize; + + @SerializedName("lastBuildTimeS") + private Integer lastBuildTimeS; + + @SerializedName("numberOfPendingTask") + private Integer numberOfPendingTask; + + @SerializedName("pendingTask") + private Boolean pendingTask; + + @SerializedName("primary") + private String primary; + + @SerializedName("replicas") + private List replicas = null; + + public FetchedIndex setName(String name) { + this.name = name; + return this; + } + + /** + * Index name. + * + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public FetchedIndex setCreatedAt(String createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Index creation date. An empty string means that the index has no records. + * + * @return createdAt + */ + @javax.annotation.Nonnull + public String getCreatedAt() { + return createdAt; + } + + public FetchedIndex setUpdatedAt(String updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nonnull + public String getUpdatedAt() { + return updatedAt; + } + + public FetchedIndex setEntries(Integer entries) { + this.entries = entries; + return this; + } + + /** + * Number of records contained in the index. + * + * @return entries + */ + @javax.annotation.Nonnull + public Integer getEntries() { + return entries; + } + + public FetchedIndex setDataSize(Integer dataSize) { + this.dataSize = dataSize; + return this; + } + + /** + * Number of bytes of the index in minified format. + * + * @return dataSize + */ + @javax.annotation.Nonnull + public Integer getDataSize() { + return dataSize; + } + + public FetchedIndex setFileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + /** + * Number of bytes of the index binary file. + * + * @return fileSize + */ + @javax.annotation.Nonnull + public Integer getFileSize() { + return fileSize; + } + + public FetchedIndex setLastBuildTimeS(Integer lastBuildTimeS) { + this.lastBuildTimeS = lastBuildTimeS; + return this; + } + + /** + * Last build time. + * + * @return lastBuildTimeS + */ + @javax.annotation.Nonnull + public Integer getLastBuildTimeS() { + return lastBuildTimeS; + } + + public FetchedIndex setNumberOfPendingTask(Integer numberOfPendingTask) { + this.numberOfPendingTask = numberOfPendingTask; + return this; + } + + /** + * Number of pending indexing operations. This value is deprecated and should not be used. + * + * @return numberOfPendingTask + */ + @javax.annotation.Nullable + public Integer getNumberOfPendingTask() { + return numberOfPendingTask; + } + + public FetchedIndex setPendingTask(Boolean pendingTask) { + this.pendingTask = pendingTask; + return this; + } + + /** + * A boolean which says whether the index has pending tasks. This value is deprecated and should + * not be used. + * + * @return pendingTask + */ + @javax.annotation.Nonnull + public Boolean getPendingTask() { + return pendingTask; + } + + public FetchedIndex setPrimary(String primary) { + this.primary = primary; + return this; + } + + /** + * Only present if the index is a replica. Contains the name of the related primary index. + * + * @return primary + */ + @javax.annotation.Nullable + public String getPrimary() { + return primary; + } + + public FetchedIndex setReplicas(List replicas) { + this.replicas = replicas; + return this; + } + + public FetchedIndex addReplicas(String replicasItem) { + if (this.replicas == null) { + this.replicas = new ArrayList<>(); + } + this.replicas.add(replicasItem); + return this; + } + + /** + * Only present if the index is a primary index with replicas. Contains the names of all linked + * replicas. + * + * @return replicas + */ + @javax.annotation.Nullable + public List getReplicas() { + return replicas; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FetchedIndex fetchedIndex = (FetchedIndex) o; + return ( + Objects.equals(this.name, fetchedIndex.name) && + Objects.equals(this.createdAt, fetchedIndex.createdAt) && + Objects.equals(this.updatedAt, fetchedIndex.updatedAt) && + Objects.equals(this.entries, fetchedIndex.entries) && + Objects.equals(this.dataSize, fetchedIndex.dataSize) && + Objects.equals(this.fileSize, fetchedIndex.fileSize) && + Objects.equals(this.lastBuildTimeS, fetchedIndex.lastBuildTimeS) && + Objects.equals( + this.numberOfPendingTask, + fetchedIndex.numberOfPendingTask + ) && + Objects.equals(this.pendingTask, fetchedIndex.pendingTask) && + Objects.equals(this.primary, fetchedIndex.primary) && + Objects.equals(this.replicas, fetchedIndex.replicas) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + createdAt, + updatedAt, + entries, + dataSize, + fileSize, + lastBuildTimeS, + numberOfPendingTask, + pendingTask, + primary, + replicas + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FetchedIndex {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb + .append(" createdAt: ") + .append(toIndentedString(createdAt)) + .append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .append("\n"); + sb.append(" entries: ").append(toIndentedString(entries)).append("\n"); + sb.append(" dataSize: ").append(toIndentedString(dataSize)).append("\n"); + sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); + sb + .append(" lastBuildTimeS: ") + .append(toIndentedString(lastBuildTimeS)) + .append("\n"); + sb + .append(" numberOfPendingTask: ") + .append(toIndentedString(numberOfPendingTask)) + .append("\n"); + sb + .append(" pendingTask: ") + .append(toIndentedString(pendingTask)) + .append("\n"); + sb.append(" primary: ").append(toIndentedString(primary)).append("\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/GetLogsResponseLogs.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/GetLogsResponseLogs.java index eaaa706a5c..2def92c743 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/GetLogsResponseLogs.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/GetLogsResponseLogs.java @@ -74,7 +74,7 @@ public GetLogsResponseLogs setMethod(String method) { } /** - * HTTP method of the perfomed request. + * HTTP method of the performed request. * * @return method */ @@ -149,7 +149,7 @@ public GetLogsResponseLogs setIp(String ip) { } /** - * IP of the client which perfomed the request. + * IP of the client which performed the request. * * @return ip */ diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ListIndicesResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ListIndicesResponse.java index cb0a7f5e7d..65eacf9ae7 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ListIndicesResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ListIndicesResponse.java @@ -9,17 +9,17 @@ public class ListIndicesResponse { @SerializedName("items") - private List items = null; + private List items = null; @SerializedName("nbPages") private Integer nbPages; - public ListIndicesResponse setItems(List items) { + public ListIndicesResponse setItems(List items) { this.items = items; return this; } - public ListIndicesResponse addItems(Indice itemsItem) { + public ListIndicesResponse addItems(FetchedIndex itemsItem) { if (this.items == null) { this.items = new ArrayList<>(); } @@ -33,7 +33,7 @@ public ListIndicesResponse addItems(Indice itemsItem) { * @return items */ @javax.annotation.Nullable - public List getItems() { + public List getItems() { return items; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponse.java index 3d7b40bae2..b7f7e1fa84 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponse.java @@ -186,7 +186,7 @@ public SearchResponse setExhaustiveTypo(Boolean exhaustiveTypo) { } /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when * typo-tolerance is enabled). * * @return exhaustiveTypo diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchResponse.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchResponse.ts index 358556c692..f20f0f5aed 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchResponse.ts @@ -26,7 +26,7 @@ export type BaseSearchResponse = { */ exhaustiveNbHits: boolean; /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled). + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). */ exhaustiveTypo: boolean; /** diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/fetchedIndex.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/fetchedIndex.ts new file mode 100644 index 0000000000..07a3eb779c --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/fetchedIndex.ts @@ -0,0 +1,46 @@ +export type FetchedIndex = { + /** + * Index name. + */ + name: string; + /** + * Index creation date. An empty string means that the index has no records. + */ + createdAt: string; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: string; + /** + * Number of records contained in the index. + */ + entries: number; + /** + * Number of bytes of the index in minified format. + */ + dataSize: number; + /** + * Number of bytes of the index binary file. + */ + fileSize: number; + /** + * Last build time. + */ + lastBuildTimeS: number; + /** + * Number of pending indexing operations. This value is deprecated and should not be used. + */ + numberOfPendingTask?: number; + /** + * A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. + */ + pendingTask: boolean; + /** + * Only present if the index is a replica. Contains the name of the related primary index. + */ + primary?: string; + /** + * Only present if the index is a primary index with replicas. Contains the names of all linked replicas. + */ + replicas?: string[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts index a89f2f216d..942b52d54e 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts @@ -30,11 +30,11 @@ export * from './dictionaryType'; export * from './errorBase'; export * from './exactOnSingleWordQuery'; export * from './facetFilters'; +export * from './fetchedIndex'; export * from './highlightResult'; export * from './hit'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; -export * from './indice'; export * from './key'; export * from './languages'; export * from './listIndicesResponse'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/listIndicesResponse.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/listIndicesResponse.ts index c89d4922ff..68c673c97c 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/listIndicesResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/listIndicesResponse.ts @@ -1,10 +1,10 @@ -import type { Indice } from './indice'; +import type { FetchedIndex } from './fetchedIndex'; export type ListIndicesResponse = { /** * List of the fetched indices. */ - items?: Indice[]; + items?: FetchedIndex[]; /** * Number of pages. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/model/abTestsVariant.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/model/abTestsVariant.ts index 5100fec263..c38ac95b45 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/model/abTestsVariant.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/model/abTestsVariant.ts @@ -4,7 +4,7 @@ export type AbTestsVariant = { */ index: string; /** - * The traffic perfecentage for the A/B test. + * The traffic percentage for the A/B test. */ trafficPercentage: number; /** diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/model/variant.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/model/variant.ts index 3328858f2b..056decec21 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/model/variant.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/model/variant.ts @@ -40,7 +40,7 @@ export type Variant = { */ trackedSearchCount: number; /** - * The traffic perfecentage for the A/B test. + * The traffic percentage for the A/B test. */ trafficPercentage: number; /** diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/index.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/index.ts index 4887f5e58e..3693285ad4 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/index.ts @@ -7,6 +7,6 @@ export * from './querySuggestionsIndexParam'; export * from './querySuggestionsIndexWithIndexParam'; export * from './sourceIndex'; export * from './sourceIndexExternal'; -export * from './sourceIndiceWithReplicas'; +export * from './sourceIndexWithReplicas'; export * from './status'; -export * from './sucessResponse'; +export * from './successResponse'; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/querySuggestionsIndex.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/querySuggestionsIndex.ts index 74ce2d5475..7169be6b83 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/querySuggestionsIndex.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/querySuggestionsIndex.ts @@ -1,4 +1,4 @@ -import type { SourceIndiceWithReplicas } from './sourceIndiceWithReplicas'; +import type { SourceIndexWithReplicas } from './sourceIndexWithReplicas'; export type QuerySuggestionsIndex = { /** @@ -8,7 +8,7 @@ export type QuerySuggestionsIndex = { /** * List of source indices used to generate a Query Suggestions index. */ - sourceIndices: SourceIndiceWithReplicas[]; + sourceIndices: SourceIndexWithReplicas[]; /** * De-duplicate singular and plural suggestions. For example, let\'s say your index contains English content, and that two suggestions “shoe” and “shoes” end up in your Query Suggestions index. If the English language is configured, only the most popular of those two suggestions would remain. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndexWithReplicas.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndexWithReplicas.ts new file mode 100644 index 0000000000..b5336c97f3 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndexWithReplicas.ts @@ -0,0 +1,39 @@ +import type { SourceIndexExternal } from './sourceIndexExternal'; + +/** + * Source index with replicas used to generate a Query Suggestions index. + */ +export type SourceIndexWithReplicas = { + /** + * True if the Query Suggestions index is a replicas. + */ + replicas: boolean; + /** + * Source index name. + */ + indexName: string; + /** + * List of analytics tags to filter the popular searches per tag. + */ + analyticsTags: string[]; + /** + * List of facets to define as categories for the query suggestions. + */ + facets: Array>; + /** + * Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. + */ + minHits: number; + /** + * Minimum number of required letters for a suggestion to remain. + */ + minLetters: number; + /** + * List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). + */ + generate: string[][]; + /** + * List of external indices to use to generate custom Query Suggestions. + */ + external: SourceIndexExternal[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/successResponse.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/successResponse.ts new file mode 100644 index 0000000000..cc3386b3f1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/successResponse.ts @@ -0,0 +1,10 @@ +export type SuccessResponse = { + /** + * The status code. + */ + status: number; + /** + * Message of the response. + */ + message: string; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsClient.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsClient.ts index 644d8ea905..9ed433e5c0 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsClient.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsClient.ts @@ -17,7 +17,7 @@ import type { QuerySuggestionsIndex } from '../model/querySuggestionsIndex'; import type { QuerySuggestionsIndexParam } from '../model/querySuggestionsIndexParam'; import type { QuerySuggestionsIndexWithIndexParam } from '../model/querySuggestionsIndexWithIndexParam'; import type { Status } from '../model/status'; -import type { SucessResponse } from '../model/sucessResponse'; +import type { SuccessResponse } from '../model/successResponse'; export * from '../model'; export const apiClientVersion = '0.2.0'; @@ -73,7 +73,7 @@ export function createQuerySuggestionsClient( createConfig( querySuggestionsIndexWithIndexParam: QuerySuggestionsIndexWithIndexParam, requestOptions?: RequestOptions - ): Promise { + ): Promise { if (!querySuggestionsIndexWithIndexParam) { throw new Error( 'Parameter `querySuggestionsIndexWithIndexParam` is required when calling `createConfig`.' @@ -137,7 +137,7 @@ export function createQuerySuggestionsClient( }, /** - * Delete a configuration of a Query Suggestion\'s index. By deleting a configuraton, you stop all updates to the underlying query suggestion index. Note that when doing this, the underlying index does not change - existing suggestions remain untouched. + * Delete a configuration of a Query Suggestion\'s index. By deleting a configuration, you stop all updates to the underlying query suggestion index. Note that when doing this, the underlying index does not change - existing suggestions remain untouched. * * @summary Delete a configuration. * @param deleteConfig - The deleteConfig object. @@ -147,7 +147,7 @@ export function createQuerySuggestionsClient( deleteConfig( { indexName }: DeleteConfigProps, requestOptions?: RequestOptions - ): Promise { + ): Promise { if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteConfig`.' @@ -448,7 +448,7 @@ export function createQuerySuggestionsClient( updateConfig( { indexName, querySuggestionsIndexParam }: UpdateConfigProps, requestOptions?: RequestOptions - ): Promise { + ): Promise { if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `updateConfig`.' diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchResponse.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchResponse.ts index 358556c692..f20f0f5aed 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchResponse.ts @@ -26,7 +26,7 @@ export type BaseSearchResponse = { */ exhaustiveNbHits: boolean; /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled). + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). */ exhaustiveTypo: boolean; /** diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/fetchedIndex.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/fetchedIndex.ts new file mode 100644 index 0000000000..07a3eb779c --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/fetchedIndex.ts @@ -0,0 +1,46 @@ +export type FetchedIndex = { + /** + * Index name. + */ + name: string; + /** + * Index creation date. An empty string means that the index has no records. + */ + createdAt: string; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: string; + /** + * Number of records contained in the index. + */ + entries: number; + /** + * Number of bytes of the index in minified format. + */ + dataSize: number; + /** + * Number of bytes of the index binary file. + */ + fileSize: number; + /** + * Last build time. + */ + lastBuildTimeS: number; + /** + * Number of pending indexing operations. This value is deprecated and should not be used. + */ + numberOfPendingTask?: number; + /** + * A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. + */ + pendingTask: boolean; + /** + * Only present if the index is a replica. Contains the name of the related primary index. + */ + primary?: string; + /** + * Only present if the index is a primary index with replicas. Contains the names of all linked replicas. + */ + replicas?: string[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/getLogsResponseLogs.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/getLogsResponseLogs.ts index 67ec3593a7..14f0c93eb0 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/getLogsResponseLogs.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/getLogsResponseLogs.ts @@ -6,7 +6,7 @@ export type GetLogsResponseLogs = { */ timestamp: string; /** - * HTTP method of the perfomed request. + * HTTP method of the performed request. */ method: string; /** @@ -26,7 +26,7 @@ export type GetLogsResponseLogs = { */ url: string; /** - * IP of the client which perfomed the request. + * IP of the client which performed the request. */ ip: string; /** diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts index 5f77472e90..b24160123e 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts @@ -44,6 +44,7 @@ export * from './dictionaryType'; export * from './errorBase'; export * from './exactOnSingleWordQuery'; export * from './facetFilters'; +export * from './fetchedIndex'; export * from './getDictionarySettingsResponse'; export * from './getLogsResponse'; export * from './getLogsResponseInnerQueries'; @@ -56,7 +57,6 @@ export * from './highlightResult'; export * from './hit'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; -export * from './indice'; export * from './key'; export * from './languages'; export * from './listApiKeysResponse'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/listIndicesResponse.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/listIndicesResponse.ts index c89d4922ff..68c673c97c 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/listIndicesResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/listIndicesResponse.ts @@ -1,10 +1,10 @@ -import type { Indice } from './indice'; +import type { FetchedIndex } from './fetchedIndex'; export type ListIndicesResponse = { /** * List of the fetched indices. */ - items?: Indice[]; + items?: FetchedIndex[]; /** * Number of pages. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts index f1bc045582..f1cc635401 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts @@ -1866,7 +1866,7 @@ export function createSearchClient(options: CreateClientOptions) { }, /** - * Peforms a copy or a move operation on a index. + * Performs a copy or a move operation on a index. * * @summary Copy/move index. * @param operationIndex - The operationIndex object. diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchResponse.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchResponse.ts index 358556c692..f20f0f5aed 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchResponse.ts @@ -26,7 +26,7 @@ export type BaseSearchResponse = { */ exhaustiveNbHits: boolean; /** - * Indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled). + * Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). */ exhaustiveTypo: boolean; /** diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php index 05dd21507a..d5d9d2231a 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php @@ -107,7 +107,7 @@ public function getClientConfig() * * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * - * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SucessResponse + * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SuccessResponse */ public function createConfig( $querySuggestionsIndexWithIndexParam, @@ -191,7 +191,7 @@ public function del($path, $parameters = null, $requestOptions = []) * @param string $indexName The index in which to perform the request. (required) * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * - * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SucessResponse + * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SuccessResponse */ public function deleteConfig($indexName, $requestOptions = []) { @@ -542,7 +542,7 @@ public function put( * * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * - * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SucessResponse + * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SuccessResponse */ public function updateConfig( $indexName, diff --git a/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariant.php b/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariant.php index e93783b7ce..addb47a627 100644 --- a/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariant.php +++ b/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariant.php @@ -195,7 +195,7 @@ public function getTrafficPercentage() /** * Sets trafficPercentage * - * @param int $trafficPercentage the traffic perfecentage for the A/B test + * @param int $trafficPercentage the traffic percentage for the A/B test * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariantSearchParams.php b/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariantSearchParams.php index b0e9591e2e..0a3498ed89 100644 --- a/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariantSearchParams.php +++ b/clients/algoliasearch-client-php/lib/Model/Abtesting/AbTestsVariantSearchParams.php @@ -209,7 +209,7 @@ public function getTrafficPercentage() /** * Sets trafficPercentage * - * @param int $trafficPercentage the traffic perfecentage for the A/B test + * @param int $trafficPercentage the traffic percentage for the A/B test * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Abtesting/AddABTestsVariant.php b/clients/algoliasearch-client-php/lib/Model/Abtesting/AddABTestsVariant.php index 11092c3251..201f2d3f2d 100644 --- a/clients/algoliasearch-client-php/lib/Model/Abtesting/AddABTestsVariant.php +++ b/clients/algoliasearch-client-php/lib/Model/Abtesting/AddABTestsVariant.php @@ -209,7 +209,7 @@ public function getTrafficPercentage() /** * Sets trafficPercentage * - * @param int $trafficPercentage the traffic perfecentage for the A/B test + * @param int $trafficPercentage the traffic percentage for the A/B test * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Abtesting/Variant.php b/clients/algoliasearch-client-php/lib/Model/Abtesting/Variant.php index bcf3ea44d4..492b7880a3 100644 --- a/clients/algoliasearch-client-php/lib/Model/Abtesting/Variant.php +++ b/clients/algoliasearch-client-php/lib/Model/Abtesting/Variant.php @@ -536,7 +536,7 @@ public function getTrafficPercentage() /** * Sets trafficPercentage * - * @param int $trafficPercentage the traffic perfecentage for the A/B test + * @param int $trafficPercentage the traffic percentage for the A/B test * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/QuerySuggestionsIndex.php b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/QuerySuggestionsIndex.php index 269ad6e719..764d9a39bc 100644 --- a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/QuerySuggestionsIndex.php +++ b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/QuerySuggestionsIndex.php @@ -20,7 +20,7 @@ class QuerySuggestionsIndex extends \Algolia\AlgoliaSearch\Model\AbstractModel i */ protected static $modelTypes = [ 'indexName' => 'string', - 'sourceIndices' => '\Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndiceWithReplicas[]', + 'sourceIndices' => '\Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexWithReplicas[]', 'languages' => 'string[]', 'exclude' => 'string[]', ]; @@ -204,7 +204,7 @@ public function setIndexName($indexName) /** * Gets sourceIndices * - * @return \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndiceWithReplicas[] + * @return \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexWithReplicas[] */ public function getSourceIndices() { @@ -214,7 +214,7 @@ public function getSourceIndices() /** * Sets sourceIndices * - * @param \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndiceWithReplicas[] $sourceIndices list of source indices used to generate a Query Suggestions index + * @param \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexWithReplicas[] $sourceIndices list of source indices used to generate a Query Suggestions index * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndexWithReplicas.php b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndexWithReplicas.php new file mode 100644 index 0000000000..f539340fd1 --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndexWithReplicas.php @@ -0,0 +1,477 @@ + 'bool', + 'indexName' => 'string', + 'analyticsTags' => 'string[]', + 'facets' => 'object[]', + 'minHits' => 'int', + 'minLetters' => 'int', + 'generate' => 'string[][]', + 'external' => '\Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexExternal[]', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $modelFormats = [ + 'replicas' => null, + 'indexName' => null, + 'analyticsTags' => null, + 'facets' => null, + 'minHits' => null, + 'minLetters' => null, + 'generate' => null, + 'external' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function modelTypes() + { + return self::$modelTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function modelFormats() + { + return self::$modelFormats; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'replicas' => 'setReplicas', + 'indexName' => 'setIndexName', + 'analyticsTags' => 'setAnalyticsTags', + 'facets' => 'setFacets', + 'minHits' => 'setMinHits', + 'minLetters' => 'setMinLetters', + 'generate' => 'setGenerate', + 'external' => 'setExternal', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'replicas' => 'getReplicas', + 'indexName' => 'getIndexName', + 'analyticsTags' => 'getAnalyticsTags', + 'facets' => 'getFacets', + 'minHits' => 'getMinHits', + 'minLetters' => 'getMinLetters', + 'generate' => 'getGenerate', + 'external' => 'getExternal', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + */ + public function __construct(array $data = null) + { + if (isset($data['replicas'])) { + $this->container['replicas'] = $data['replicas']; + } + if (isset($data['indexName'])) { + $this->container['indexName'] = $data['indexName']; + } + if (isset($data['analyticsTags'])) { + $this->container['analyticsTags'] = $data['analyticsTags']; + } + if (isset($data['facets'])) { + $this->container['facets'] = $data['facets']; + } + if (isset($data['minHits'])) { + $this->container['minHits'] = $data['minHits']; + } + if (isset($data['minLetters'])) { + $this->container['minLetters'] = $data['minLetters']; + } + if (isset($data['generate'])) { + $this->container['generate'] = $data['generate']; + } + if (isset($data['external'])) { + $this->container['external'] = $data['external']; + } + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ( + !isset($this->container['replicas']) || + $this->container['replicas'] === null + ) { + $invalidProperties[] = "'replicas' can't be null"; + } + if ( + !isset($this->container['indexName']) || + $this->container['indexName'] === null + ) { + $invalidProperties[] = "'indexName' can't be null"; + } + if ( + !isset($this->container['analyticsTags']) || + $this->container['analyticsTags'] === null + ) { + $invalidProperties[] = "'analyticsTags' can't be null"; + } + if ( + !isset($this->container['facets']) || + $this->container['facets'] === null + ) { + $invalidProperties[] = "'facets' can't be null"; + } + if ( + !isset($this->container['minHits']) || + $this->container['minHits'] === null + ) { + $invalidProperties[] = "'minHits' can't be null"; + } + if ( + !isset($this->container['minLetters']) || + $this->container['minLetters'] === null + ) { + $invalidProperties[] = "'minLetters' can't be null"; + } + if ( + !isset($this->container['generate']) || + $this->container['generate'] === null + ) { + $invalidProperties[] = "'generate' can't be null"; + } + if ( + !isset($this->container['external']) || + $this->container['external'] === null + ) { + $invalidProperties[] = "'external' can't be null"; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Gets replicas + * + * @return bool + */ + public function getReplicas() + { + return $this->container['replicas'] ?? null; + } + + /** + * Sets replicas + * + * @param bool $replicas true if the Query Suggestions index is a replicas + * + * @return self + */ + public function setReplicas($replicas) + { + $this->container['replicas'] = $replicas; + + return $this; + } + + /** + * Gets indexName + * + * @return string + */ + public function getIndexName() + { + return $this->container['indexName'] ?? null; + } + + /** + * Sets indexName + * + * @param string $indexName source index name + * + * @return self + */ + public function setIndexName($indexName) + { + $this->container['indexName'] = $indexName; + + return $this; + } + + /** + * Gets analyticsTags + * + * @return string[] + */ + public function getAnalyticsTags() + { + return $this->container['analyticsTags'] ?? null; + } + + /** + * Sets analyticsTags + * + * @param string[] $analyticsTags list of analytics tags to filter the popular searches per tag + * + * @return self + */ + public function setAnalyticsTags($analyticsTags) + { + $this->container['analyticsTags'] = $analyticsTags; + + return $this; + } + + /** + * Gets facets + * + * @return object[] + */ + public function getFacets() + { + return $this->container['facets'] ?? null; + } + + /** + * Sets facets + * + * @param object[] $facets list of facets to define as categories for the query suggestions + * + * @return self + */ + public function setFacets($facets) + { + $this->container['facets'] = $facets; + + return $this; + } + + /** + * Gets minHits + * + * @return int + */ + public function getMinHits() + { + return $this->container['minHits'] ?? null; + } + + /** + * Sets minHits + * + * @param int $minHits Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. + * + * @return self + */ + public function setMinHits($minHits) + { + $this->container['minHits'] = $minHits; + + return $this; + } + + /** + * Gets minLetters + * + * @return int + */ + public function getMinLetters() + { + return $this->container['minLetters'] ?? null; + } + + /** + * Sets minLetters + * + * @param int $minLetters minimum number of required letters for a suggestion to remain + * + * @return self + */ + public function setMinLetters($minLetters) + { + $this->container['minLetters'] = $minLetters; + + return $this; + } + + /** + * Gets generate + * + * @return string[][] + */ + public function getGenerate() + { + return $this->container['generate'] ?? null; + } + + /** + * Sets generate + * + * @param string[][] $generate List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). + * + * @return self + */ + public function setGenerate($generate) + { + $this->container['generate'] = $generate; + + return $this; + } + + /** + * Gets external + * + * @return \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexExternal[] + */ + public function getExternal() + { + return $this->container['external'] ?? null; + } + + /** + * Sets external + * + * @param \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexExternal[] $external list of external indices to use to generate custom Query Suggestions + * + * @return self + */ + public function setExternal($external) + { + $this->container['external'] = $external; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} diff --git a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SuccessResponse.php b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SuccessResponse.php new file mode 100644 index 0000000000..ed9bcc306c --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SuccessResponse.php @@ -0,0 +1,253 @@ + 'int', + 'message' => 'string', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $modelFormats = [ + 'status' => null, + 'message' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function modelTypes() + { + return self::$modelTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function modelFormats() + { + return self::$modelFormats; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'status' => 'setStatus', + 'message' => 'setMessage', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'status' => 'getStatus', + 'message' => 'getMessage', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + */ + public function __construct(array $data = null) + { + if (isset($data['status'])) { + $this->container['status'] = $data['status']; + } + if (isset($data['message'])) { + $this->container['message'] = $data['message']; + } + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ( + !isset($this->container['status']) || + $this->container['status'] === null + ) { + $invalidProperties[] = "'status' can't be null"; + } + if ( + !isset($this->container['message']) || + $this->container['message'] === null + ) { + $invalidProperties[] = "'message' can't be null"; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Gets status + * + * @return int + */ + public function getStatus() + { + return $this->container['status'] ?? null; + } + + /** + * Sets status + * + * @param int $status the status code + * + * @return self + */ + public function setStatus($status) + { + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message'] ?? null; + } + + /** + * Sets message + * + * @param string $message message of the response + * + * @return self + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} diff --git a/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchResponse.php b/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchResponse.php index 2c53abfb6f..04292513a4 100644 --- a/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchResponse.php +++ b/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchResponse.php @@ -528,7 +528,7 @@ public function getExhaustiveTypo() /** * Sets exhaustiveTypo * - * @param bool $exhaustiveTypo indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled) + * @param bool $exhaustiveTypo indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled) * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Recommend/RecommendationsResponse.php b/clients/algoliasearch-client-php/lib/Model/Recommend/RecommendationsResponse.php index ec5302c6b3..ca4a3197cd 100644 --- a/clients/algoliasearch-client-php/lib/Model/Recommend/RecommendationsResponse.php +++ b/clients/algoliasearch-client-php/lib/Model/Recommend/RecommendationsResponse.php @@ -541,7 +541,7 @@ public function getExhaustiveTypo() /** * Sets exhaustiveTypo * - * @param bool $exhaustiveTypo indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled) + * @param bool $exhaustiveTypo indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled) * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchResponse.php b/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchResponse.php index ab33c037c7..66ccbd278a 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchResponse.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchResponse.php @@ -528,7 +528,7 @@ public function getExhaustiveTypo() /** * Sets exhaustiveTypo * - * @param bool $exhaustiveTypo indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled) + * @param bool $exhaustiveTypo indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled) * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Search/BrowseResponse.php b/clients/algoliasearch-client-php/lib/Model/Search/BrowseResponse.php index 8ba660bad1..f84dedb158 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/BrowseResponse.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/BrowseResponse.php @@ -554,7 +554,7 @@ public function getExhaustiveTypo() /** * Sets exhaustiveTypo * - * @param bool $exhaustiveTypo indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled) + * @param bool $exhaustiveTypo indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled) * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Search/FetchedIndex.php b/clients/algoliasearch-client-php/lib/Model/Search/FetchedIndex.php new file mode 100644 index 0000000000..f8b2089be3 --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/Search/FetchedIndex.php @@ -0,0 +1,569 @@ + 'string', + 'createdAt' => 'string', + 'updatedAt' => 'string', + 'entries' => 'int', + 'dataSize' => 'int', + 'fileSize' => 'int', + 'lastBuildTimeS' => 'int', + 'numberOfPendingTask' => 'int', + 'pendingTask' => 'bool', + 'primary' => 'string', + 'replicas' => 'string[]', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $modelFormats = [ + 'name' => null, + 'createdAt' => null, + 'updatedAt' => null, + 'entries' => null, + 'dataSize' => null, + 'fileSize' => null, + 'lastBuildTimeS' => null, + 'numberOfPendingTask' => null, + 'pendingTask' => null, + 'primary' => null, + 'replicas' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function modelTypes() + { + return self::$modelTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function modelFormats() + { + return self::$modelFormats; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'createdAt' => 'setCreatedAt', + 'updatedAt' => 'setUpdatedAt', + 'entries' => 'setEntries', + 'dataSize' => 'setDataSize', + 'fileSize' => 'setFileSize', + 'lastBuildTimeS' => 'setLastBuildTimeS', + 'numberOfPendingTask' => 'setNumberOfPendingTask', + 'pendingTask' => 'setPendingTask', + 'primary' => 'setPrimary', + 'replicas' => 'setReplicas', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'createdAt' => 'getCreatedAt', + 'updatedAt' => 'getUpdatedAt', + 'entries' => 'getEntries', + 'dataSize' => 'getDataSize', + 'fileSize' => 'getFileSize', + 'lastBuildTimeS' => 'getLastBuildTimeS', + 'numberOfPendingTask' => 'getNumberOfPendingTask', + 'pendingTask' => 'getPendingTask', + 'primary' => 'getPrimary', + 'replicas' => 'getReplicas', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + */ + public function __construct(array $data = null) + { + if (isset($data['name'])) { + $this->container['name'] = $data['name']; + } + if (isset($data['createdAt'])) { + $this->container['createdAt'] = $data['createdAt']; + } + if (isset($data['updatedAt'])) { + $this->container['updatedAt'] = $data['updatedAt']; + } + if (isset($data['entries'])) { + $this->container['entries'] = $data['entries']; + } + if (isset($data['dataSize'])) { + $this->container['dataSize'] = $data['dataSize']; + } + if (isset($data['fileSize'])) { + $this->container['fileSize'] = $data['fileSize']; + } + if (isset($data['lastBuildTimeS'])) { + $this->container['lastBuildTimeS'] = $data['lastBuildTimeS']; + } + if (isset($data['numberOfPendingTask'])) { + $this->container['numberOfPendingTask'] = + $data['numberOfPendingTask']; + } + if (isset($data['pendingTask'])) { + $this->container['pendingTask'] = $data['pendingTask']; + } + if (isset($data['primary'])) { + $this->container['primary'] = $data['primary']; + } + if (isset($data['replicas'])) { + $this->container['replicas'] = $data['replicas']; + } + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ( + !isset($this->container['name']) || + $this->container['name'] === null + ) { + $invalidProperties[] = "'name' can't be null"; + } + if ( + !isset($this->container['createdAt']) || + $this->container['createdAt'] === null + ) { + $invalidProperties[] = "'createdAt' can't be null"; + } + if ( + !isset($this->container['updatedAt']) || + $this->container['updatedAt'] === null + ) { + $invalidProperties[] = "'updatedAt' can't be null"; + } + if ( + !isset($this->container['entries']) || + $this->container['entries'] === null + ) { + $invalidProperties[] = "'entries' can't be null"; + } + if ( + !isset($this->container['dataSize']) || + $this->container['dataSize'] === null + ) { + $invalidProperties[] = "'dataSize' can't be null"; + } + if ( + !isset($this->container['fileSize']) || + $this->container['fileSize'] === null + ) { + $invalidProperties[] = "'fileSize' can't be null"; + } + if ( + !isset($this->container['lastBuildTimeS']) || + $this->container['lastBuildTimeS'] === null + ) { + $invalidProperties[] = "'lastBuildTimeS' can't be null"; + } + if ( + !isset($this->container['pendingTask']) || + $this->container['pendingTask'] === null + ) { + $invalidProperties[] = "'pendingTask' can't be null"; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name'] ?? null; + } + + /** + * Sets name + * + * @param string $name index name + * + * @return self + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets createdAt + * + * @return string + */ + public function getCreatedAt() + { + return $this->container['createdAt'] ?? null; + } + + /** + * Sets createdAt + * + * @param string $createdAt Index creation date. An empty string means that the index has no records. + * + * @return self + */ + public function setCreatedAt($createdAt) + { + $this->container['createdAt'] = $createdAt; + + return $this; + } + + /** + * Gets updatedAt + * + * @return string + */ + public function getUpdatedAt() + { + return $this->container['updatedAt'] ?? null; + } + + /** + * Sets updatedAt + * + * @param string $updatedAt date of last update (ISO-8601 format) + * + * @return self + */ + public function setUpdatedAt($updatedAt) + { + $this->container['updatedAt'] = $updatedAt; + + return $this; + } + + /** + * Gets entries + * + * @return int + */ + public function getEntries() + { + return $this->container['entries'] ?? null; + } + + /** + * Sets entries + * + * @param int $entries number of records contained in the index + * + * @return self + */ + public function setEntries($entries) + { + $this->container['entries'] = $entries; + + return $this; + } + + /** + * Gets dataSize + * + * @return int + */ + public function getDataSize() + { + return $this->container['dataSize'] ?? null; + } + + /** + * Sets dataSize + * + * @param int $dataSize number of bytes of the index in minified format + * + * @return self + */ + public function setDataSize($dataSize) + { + $this->container['dataSize'] = $dataSize; + + return $this; + } + + /** + * Gets fileSize + * + * @return int + */ + public function getFileSize() + { + return $this->container['fileSize'] ?? null; + } + + /** + * Sets fileSize + * + * @param int $fileSize number of bytes of the index binary file + * + * @return self + */ + public function setFileSize($fileSize) + { + $this->container['fileSize'] = $fileSize; + + return $this; + } + + /** + * Gets lastBuildTimeS + * + * @return int + */ + public function getLastBuildTimeS() + { + return $this->container['lastBuildTimeS'] ?? null; + } + + /** + * Sets lastBuildTimeS + * + * @param int $lastBuildTimeS last build time + * + * @return self + */ + public function setLastBuildTimeS($lastBuildTimeS) + { + $this->container['lastBuildTimeS'] = $lastBuildTimeS; + + return $this; + } + + /** + * Gets numberOfPendingTask + * + * @return int|null + */ + public function getNumberOfPendingTask() + { + return $this->container['numberOfPendingTask'] ?? null; + } + + /** + * Sets numberOfPendingTask + * + * @param int|null $numberOfPendingTask Number of pending indexing operations. This value is deprecated and should not be used. + * + * @return self + */ + public function setNumberOfPendingTask($numberOfPendingTask) + { + $this->container['numberOfPendingTask'] = $numberOfPendingTask; + + return $this; + } + + /** + * Gets pendingTask + * + * @return bool + */ + public function getPendingTask() + { + return $this->container['pendingTask'] ?? null; + } + + /** + * Sets pendingTask + * + * @param bool $pendingTask A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. + * + * @return self + */ + public function setPendingTask($pendingTask) + { + $this->container['pendingTask'] = $pendingTask; + + return $this; + } + + /** + * Gets primary + * + * @return string|null + */ + public function getPrimary() + { + return $this->container['primary'] ?? null; + } + + /** + * Sets primary + * + * @param string|null $primary Only present if the index is a replica. Contains the name of the related primary index. + * + * @return self + */ + public function setPrimary($primary) + { + $this->container['primary'] = $primary; + + return $this; + } + + /** + * Gets replicas + * + * @return string[]|null + */ + public function getReplicas() + { + return $this->container['replicas'] ?? null; + } + + /** + * Sets replicas + * + * @param string[]|null $replicas Only present if the index is a primary index with replicas. Contains the names of all linked replicas. + * + * @return self + */ + public function setReplicas($replicas) + { + $this->container['replicas'] = $replicas; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/GetLogsResponseLogs.php b/clients/algoliasearch-client-php/lib/Model/Search/GetLogsResponseLogs.php index 421006a916..afd0b0a718 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/GetLogsResponseLogs.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/GetLogsResponseLogs.php @@ -330,7 +330,7 @@ public function getMethod() /** * Sets method * - * @param string $method HTTP method of the perfomed request + * @param string $method HTTP method of the performed request * * @return self */ @@ -450,7 +450,7 @@ public function getIp() /** * Sets ip * - * @param string $ip IP of the client which perfomed the request + * @param string $ip IP of the client which performed the request * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Search/ListIndicesResponse.php b/clients/algoliasearch-client-php/lib/Model/Search/ListIndicesResponse.php index 86c779a777..7fbd18e201 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/ListIndicesResponse.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/ListIndicesResponse.php @@ -19,7 +19,7 @@ class ListIndicesResponse extends \Algolia\AlgoliaSearch\Model\AbstractModel imp * @var string[] */ protected static $modelTypes = [ - 'items' => '\Algolia\AlgoliaSearch\Model\Search\Indice[]', + 'items' => '\Algolia\AlgoliaSearch\Model\Search\FetchedIndex[]', 'nbPages' => 'int', ]; @@ -141,7 +141,7 @@ public function valid() /** * Gets items * - * @return \Algolia\AlgoliaSearch\Model\Search\Indice[]|null + * @return \Algolia\AlgoliaSearch\Model\Search\FetchedIndex[]|null */ public function getItems() { @@ -151,7 +151,7 @@ public function getItems() /** * Sets items * - * @param \Algolia\AlgoliaSearch\Model\Search\Indice[]|null $items list of the fetched indices + * @param \Algolia\AlgoliaSearch\Model\Search\FetchedIndex[]|null $items list of the fetched indices * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchResponse.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchResponse.php index 9d1cd4362d..a5cec95047 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/SearchResponse.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchResponse.php @@ -541,7 +541,7 @@ public function getExhaustiveTypo() /** * Sets exhaustiveTypo * - * @param bool $exhaustiveTypo indicate if the typo-tolerence search was exhaustive or approximate (only included when typo-tolerance is enabled) + * @param bool $exhaustiveTypo indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled) * * @return self */ diff --git a/specs/bundled/abtesting.yml b/specs/bundled/abtesting.yml index b4fdcbedb9..3ac673b88d 100644 --- a/specs/bundled/abtesting.yml +++ b/specs/bundled/abtesting.yml @@ -87,7 +87,7 @@ components: description: The number of tracked search click. trafficPercentage: type: integer - description: The traffic perfecentage for the A/B test. + description: The traffic percentage for the A/B test. variant: type: object additionalProperties: false diff --git a/specs/bundled/algoliasearch-lite.yml b/specs/bundled/algoliasearch-lite.yml index 76a1331944..e4223ed7b4 100644 --- a/specs/bundled/algoliasearch-lite.yml +++ b/specs/bundled/algoliasearch-lite.yml @@ -771,7 +771,7 @@ components: exhaustiveTypo: type: boolean description: >- - Indicate if the typo-tolerence search was exhaustive or approximate + Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). facets: type: object @@ -1760,7 +1760,7 @@ components: - settings - synonyms - rules - indice: + fetchedIndex: type: object additionalProperties: false properties: @@ -1825,7 +1825,7 @@ components: type: array description: List of the fetched indices. items: - $ref: '#/components/schemas/indice' + $ref: '#/components/schemas/fetchedIndex' nbPages: type: integer description: Number of pages. @@ -1952,8 +1952,8 @@ tags: description: Manage your Api Keys. - name: Clusters description: Clusters operations. - - name: Dictionnaries - description: Dictionnaries operations. + - name: Dictionaries + description: Dictionaries operations. - name: Indices description: Manage indices. - name: Records @@ -1980,7 +1980,7 @@ x-tagGroups: tags: - Rules - Synonyms - - Dictionnaries + - Dictionaries - name: Others tags: - Api Keys diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index 7b788469bf..322e924c10 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -101,10 +101,10 @@ components: items: $ref: '#/components/schemas/SourceIndexExternal' description: List of external indices to use to generate custom Query Suggestions. - SourceIndiceWithReplicas: + SourceIndexWithReplicas: type: object additionalProperties: false - description: Source indice with replicas used to generate a Query Suggestions index. + description: Source index with replicas used to generate a Query Suggestions index. required: - replicas - indexName @@ -136,7 +136,7 @@ components: type: array description: List of source indices used to generate a Query Suggestions index. items: - $ref: '#/components/schemas/SourceIndiceWithReplicas' + $ref: '#/components/schemas/SourceIndexWithReplicas' QuerySuggestionsIndex: type: object additionalProperties: false @@ -286,7 +286,7 @@ components: application/json: schema: type: object - title: SucessResponse + title: SuccessResponse additionalProperties: false required: - status @@ -545,8 +545,8 @@ paths: description: > Delete a configuration of a Query Suggestion's index. - By deleting a configuraton, you stop all updates to the underlying query - suggestion index. + By deleting a configuration, you stop all updates to the underlying + query suggestion index. Note that when doing this, the underlying index does not change - existing suggestions remain untouched. diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 34a50f2028..10328a1c3f 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -723,7 +723,7 @@ components: exhaustiveTypo: type: boolean description: >- - Indicate if the typo-tolerence search was exhaustive or approximate + Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). facets: type: object diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 2053eb4ce4..27278c1c6f 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -771,7 +771,7 @@ components: exhaustiveTypo: type: boolean description: >- - Indicate if the typo-tolerence search was exhaustive or approximate + Indicate if the typo-tolerance search was exhaustive or approximate (only included when typo-tolerance is enabled). facets: type: object @@ -1760,7 +1760,7 @@ components: - settings - synonyms - rules - indice: + fetchedIndex: type: object additionalProperties: false properties: @@ -1825,7 +1825,7 @@ components: type: array description: List of the fetched indices. items: - $ref: '#/components/schemas/indice' + $ref: '#/components/schemas/fetchedIndex' nbPages: type: integer description: Number of pages. @@ -1952,8 +1952,8 @@ tags: description: Manage your Api Keys. - name: Clusters description: Clusters operations. - - name: Dictionnaries - description: Dictionnaries operations. + - name: Dictionaries + description: Dictionaries operations. - name: Indices description: Manage indices. - name: Records @@ -1980,7 +1980,7 @@ x-tagGroups: tags: - Rules - Synonyms - - Dictionnaries + - Dictionaries - name: Others tags: - Api Keys @@ -4150,7 +4150,7 @@ paths: description: Timestamp in ISO-8601 format. method: type: string - description: HTTP method of the perfomed request. + description: HTTP method of the performed request. answer_code: type: string description: HTTP response code. @@ -4165,7 +4165,7 @@ paths: description: Request URL. ip: type: string - description: IP of the client which perfomed the request. + description: IP of the client which performed the request. query_headers: type: string description: Request Headers (API Key is obfuscated). @@ -4271,7 +4271,7 @@ paths: - search operationId: operationIndex summary: Copy/move index. - description: Peforms a copy or a move operation on a index. + description: Performs a copy or a move operation on a index. parameters: - $ref: '#/components/parameters/IndexName' requestBody: From 3f9309f61844ace3f8b918cdacb225f091a84ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Thu, 19 May 2022 14:37:03 +0200 Subject: [PATCH 4/8] chore: remove old models (#515) --- .../java/com/algolia/model/search/Indice.java | 303 ---------- .../algoliasearch-lite/model/indice.ts | 46 -- .../model/sourceIndiceWithReplicas.ts | 39 -- .../model/sucessResponse.ts | 10 - .../packages/client-search/model/indice.ts | 46 -- .../SourceIndiceWithReplicas.php | 477 --------------- .../Model/QuerySuggestions/SucessResponse.php | 253 -------- .../lib/Model/Search/Indice.php | 569 ------------------ 8 files changed, 1743 deletions(-) delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/Indice.java delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/indice.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndiceWithReplicas.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sucessResponse.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/indice.ts delete mode 100644 clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndiceWithReplicas.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SucessResponse.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/Indice.php diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/Indice.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/Indice.java deleted file mode 100644 index dd6f74f002..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/Indice.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** Indice */ -public class Indice { - - @SerializedName("name") - private String name; - - @SerializedName("createdAt") - private String createdAt; - - @SerializedName("updatedAt") - private String updatedAt; - - @SerializedName("entries") - private Integer entries; - - @SerializedName("dataSize") - private Integer dataSize; - - @SerializedName("fileSize") - private Integer fileSize; - - @SerializedName("lastBuildTimeS") - private Integer lastBuildTimeS; - - @SerializedName("numberOfPendingTask") - private Integer numberOfPendingTask; - - @SerializedName("pendingTask") - private Boolean pendingTask; - - @SerializedName("primary") - private String primary; - - @SerializedName("replicas") - private List replicas = null; - - public Indice setName(String name) { - this.name = name; - return this; - } - - /** - * Index name. - * - * @return name - */ - @javax.annotation.Nonnull - public String getName() { - return name; - } - - public Indice setCreatedAt(String createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - * Index creation date. An empty string means that the index has no records. - * - * @return createdAt - */ - @javax.annotation.Nonnull - public String getCreatedAt() { - return createdAt; - } - - public Indice setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - /** - * Date of last update (ISO-8601 format). - * - * @return updatedAt - */ - @javax.annotation.Nonnull - public String getUpdatedAt() { - return updatedAt; - } - - public Indice setEntries(Integer entries) { - this.entries = entries; - return this; - } - - /** - * Number of records contained in the index. - * - * @return entries - */ - @javax.annotation.Nonnull - public Integer getEntries() { - return entries; - } - - public Indice setDataSize(Integer dataSize) { - this.dataSize = dataSize; - return this; - } - - /** - * Number of bytes of the index in minified format. - * - * @return dataSize - */ - @javax.annotation.Nonnull - public Integer getDataSize() { - return dataSize; - } - - public Indice setFileSize(Integer fileSize) { - this.fileSize = fileSize; - return this; - } - - /** - * Number of bytes of the index binary file. - * - * @return fileSize - */ - @javax.annotation.Nonnull - public Integer getFileSize() { - return fileSize; - } - - public Indice setLastBuildTimeS(Integer lastBuildTimeS) { - this.lastBuildTimeS = lastBuildTimeS; - return this; - } - - /** - * Last build time. - * - * @return lastBuildTimeS - */ - @javax.annotation.Nonnull - public Integer getLastBuildTimeS() { - return lastBuildTimeS; - } - - public Indice setNumberOfPendingTask(Integer numberOfPendingTask) { - this.numberOfPendingTask = numberOfPendingTask; - return this; - } - - /** - * Number of pending indexing operations. This value is deprecated and should not be used. - * - * @return numberOfPendingTask - */ - @javax.annotation.Nullable - public Integer getNumberOfPendingTask() { - return numberOfPendingTask; - } - - public Indice setPendingTask(Boolean pendingTask) { - this.pendingTask = pendingTask; - return this; - } - - /** - * A boolean which says whether the index has pending tasks. This value is deprecated and should - * not be used. - * - * @return pendingTask - */ - @javax.annotation.Nonnull - public Boolean getPendingTask() { - return pendingTask; - } - - public Indice setPrimary(String primary) { - this.primary = primary; - return this; - } - - /** - * Only present if the index is a replica. Contains the name of the related primary index. - * - * @return primary - */ - @javax.annotation.Nullable - public String getPrimary() { - return primary; - } - - public Indice setReplicas(List replicas) { - this.replicas = replicas; - return this; - } - - public Indice addReplicas(String replicasItem) { - if (this.replicas == null) { - this.replicas = new ArrayList<>(); - } - this.replicas.add(replicasItem); - return this; - } - - /** - * Only present if the index is a primary index with replicas. Contains the names of all linked - * replicas. - * - * @return replicas - */ - @javax.annotation.Nullable - public List getReplicas() { - return replicas; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Indice indice = (Indice) o; - return ( - Objects.equals(this.name, indice.name) && - Objects.equals(this.createdAt, indice.createdAt) && - Objects.equals(this.updatedAt, indice.updatedAt) && - Objects.equals(this.entries, indice.entries) && - Objects.equals(this.dataSize, indice.dataSize) && - Objects.equals(this.fileSize, indice.fileSize) && - Objects.equals(this.lastBuildTimeS, indice.lastBuildTimeS) && - Objects.equals(this.numberOfPendingTask, indice.numberOfPendingTask) && - Objects.equals(this.pendingTask, indice.pendingTask) && - Objects.equals(this.primary, indice.primary) && - Objects.equals(this.replicas, indice.replicas) - ); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - createdAt, - updatedAt, - entries, - dataSize, - fileSize, - lastBuildTimeS, - numberOfPendingTask, - pendingTask, - primary, - replicas - ); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Indice {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb - .append(" createdAt: ") - .append(toIndentedString(createdAt)) - .append("\n"); - sb - .append(" updatedAt: ") - .append(toIndentedString(updatedAt)) - .append("\n"); - sb.append(" entries: ").append(toIndentedString(entries)).append("\n"); - sb.append(" dataSize: ").append(toIndentedString(dataSize)).append("\n"); - sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); - sb - .append(" lastBuildTimeS: ") - .append(toIndentedString(lastBuildTimeS)) - .append("\n"); - sb - .append(" numberOfPendingTask: ") - .append(toIndentedString(numberOfPendingTask)) - .append("\n"); - sb - .append(" pendingTask: ") - .append(toIndentedString(pendingTask)) - .append("\n"); - sb.append(" primary: ").append(toIndentedString(primary)).append("\n"); - sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/indice.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/indice.ts deleted file mode 100644 index b5c963c297..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/indice.ts +++ /dev/null @@ -1,46 +0,0 @@ -export type Indice = { - /** - * Index name. - */ - name: string; - /** - * Index creation date. An empty string means that the index has no records. - */ - createdAt: string; - /** - * Date of last update (ISO-8601 format). - */ - updatedAt: string; - /** - * Number of records contained in the index. - */ - entries: number; - /** - * Number of bytes of the index in minified format. - */ - dataSize: number; - /** - * Number of bytes of the index binary file. - */ - fileSize: number; - /** - * Last build time. - */ - lastBuildTimeS: number; - /** - * Number of pending indexing operations. This value is deprecated and should not be used. - */ - numberOfPendingTask?: number; - /** - * A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. - */ - pendingTask: boolean; - /** - * Only present if the index is a replica. Contains the name of the related primary index. - */ - primary?: string; - /** - * Only present if the index is a primary index with replicas. Contains the names of all linked replicas. - */ - replicas?: string[]; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndiceWithReplicas.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndiceWithReplicas.ts deleted file mode 100644 index 0c3601e84a..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sourceIndiceWithReplicas.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { SourceIndexExternal } from './sourceIndexExternal'; - -/** - * Source indice with replicas used to generate a Query Suggestions index. - */ -export type SourceIndiceWithReplicas = { - /** - * True if the Query Suggestions index is a replicas. - */ - replicas: boolean; - /** - * Source index name. - */ - indexName: string; - /** - * List of analytics tags to filter the popular searches per tag. - */ - analyticsTags: string[]; - /** - * List of facets to define as categories for the query suggestions. - */ - facets: Array>; - /** - * Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. - */ - minHits: number; - /** - * Minimum number of required letters for a suggestion to remain. - */ - minLetters: number; - /** - * List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). - */ - generate: string[][]; - /** - * List of external indices to use to generate custom Query Suggestions. - */ - external: SourceIndexExternal[]; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sucessResponse.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sucessResponse.ts deleted file mode 100644 index 841e28fdb3..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/model/sucessResponse.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type SucessResponse = { - /** - * The status code. - */ - status: number; - /** - * Message of the response. - */ - message: string; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/indice.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/indice.ts deleted file mode 100644 index b5c963c297..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/indice.ts +++ /dev/null @@ -1,46 +0,0 @@ -export type Indice = { - /** - * Index name. - */ - name: string; - /** - * Index creation date. An empty string means that the index has no records. - */ - createdAt: string; - /** - * Date of last update (ISO-8601 format). - */ - updatedAt: string; - /** - * Number of records contained in the index. - */ - entries: number; - /** - * Number of bytes of the index in minified format. - */ - dataSize: number; - /** - * Number of bytes of the index binary file. - */ - fileSize: number; - /** - * Last build time. - */ - lastBuildTimeS: number; - /** - * Number of pending indexing operations. This value is deprecated and should not be used. - */ - numberOfPendingTask?: number; - /** - * A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. - */ - pendingTask: boolean; - /** - * Only present if the index is a replica. Contains the name of the related primary index. - */ - primary?: string; - /** - * Only present if the index is a primary index with replicas. Contains the names of all linked replicas. - */ - replicas?: string[]; -}; diff --git a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndiceWithReplicas.php b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndiceWithReplicas.php deleted file mode 100644 index 8ce14baf50..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SourceIndiceWithReplicas.php +++ /dev/null @@ -1,477 +0,0 @@ - 'bool', - 'indexName' => 'string', - 'analyticsTags' => 'string[]', - 'facets' => 'object[]', - 'minHits' => 'int', - 'minLetters' => 'int', - 'generate' => 'string[][]', - 'external' => '\Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexExternal[]', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'replicas' => null, - 'indexName' => null, - 'analyticsTags' => null, - 'facets' => null, - 'minHits' => null, - 'minLetters' => null, - 'generate' => null, - 'external' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'replicas' => 'setReplicas', - 'indexName' => 'setIndexName', - 'analyticsTags' => 'setAnalyticsTags', - 'facets' => 'setFacets', - 'minHits' => 'setMinHits', - 'minLetters' => 'setMinLetters', - 'generate' => 'setGenerate', - 'external' => 'setExternal', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'replicas' => 'getReplicas', - 'indexName' => 'getIndexName', - 'analyticsTags' => 'getAnalyticsTags', - 'facets' => 'getFacets', - 'minHits' => 'getMinHits', - 'minLetters' => 'getMinLetters', - 'generate' => 'getGenerate', - 'external' => 'getExternal', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['replicas'])) { - $this->container['replicas'] = $data['replicas']; - } - if (isset($data['indexName'])) { - $this->container['indexName'] = $data['indexName']; - } - if (isset($data['analyticsTags'])) { - $this->container['analyticsTags'] = $data['analyticsTags']; - } - if (isset($data['facets'])) { - $this->container['facets'] = $data['facets']; - } - if (isset($data['minHits'])) { - $this->container['minHits'] = $data['minHits']; - } - if (isset($data['minLetters'])) { - $this->container['minLetters'] = $data['minLetters']; - } - if (isset($data['generate'])) { - $this->container['generate'] = $data['generate']; - } - if (isset($data['external'])) { - $this->container['external'] = $data['external']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['replicas']) || - $this->container['replicas'] === null - ) { - $invalidProperties[] = "'replicas' can't be null"; - } - if ( - !isset($this->container['indexName']) || - $this->container['indexName'] === null - ) { - $invalidProperties[] = "'indexName' can't be null"; - } - if ( - !isset($this->container['analyticsTags']) || - $this->container['analyticsTags'] === null - ) { - $invalidProperties[] = "'analyticsTags' can't be null"; - } - if ( - !isset($this->container['facets']) || - $this->container['facets'] === null - ) { - $invalidProperties[] = "'facets' can't be null"; - } - if ( - !isset($this->container['minHits']) || - $this->container['minHits'] === null - ) { - $invalidProperties[] = "'minHits' can't be null"; - } - if ( - !isset($this->container['minLetters']) || - $this->container['minLetters'] === null - ) { - $invalidProperties[] = "'minLetters' can't be null"; - } - if ( - !isset($this->container['generate']) || - $this->container['generate'] === null - ) { - $invalidProperties[] = "'generate' can't be null"; - } - if ( - !isset($this->container['external']) || - $this->container['external'] === null - ) { - $invalidProperties[] = "'external' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets replicas - * - * @return bool - */ - public function getReplicas() - { - return $this->container['replicas'] ?? null; - } - - /** - * Sets replicas - * - * @param bool $replicas true if the Query Suggestions index is a replicas - * - * @return self - */ - public function setReplicas($replicas) - { - $this->container['replicas'] = $replicas; - - return $this; - } - - /** - * Gets indexName - * - * @return string - */ - public function getIndexName() - { - return $this->container['indexName'] ?? null; - } - - /** - * Sets indexName - * - * @param string $indexName source index name - * - * @return self - */ - public function setIndexName($indexName) - { - $this->container['indexName'] = $indexName; - - return $this; - } - - /** - * Gets analyticsTags - * - * @return string[] - */ - public function getAnalyticsTags() - { - return $this->container['analyticsTags'] ?? null; - } - - /** - * Sets analyticsTags - * - * @param string[] $analyticsTags list of analytics tags to filter the popular searches per tag - * - * @return self - */ - public function setAnalyticsTags($analyticsTags) - { - $this->container['analyticsTags'] = $analyticsTags; - - return $this; - } - - /** - * Gets facets - * - * @return object[] - */ - public function getFacets() - { - return $this->container['facets'] ?? null; - } - - /** - * Sets facets - * - * @param object[] $facets list of facets to define as categories for the query suggestions - * - * @return self - */ - public function setFacets($facets) - { - $this->container['facets'] = $facets; - - return $this; - } - - /** - * Gets minHits - * - * @return int - */ - public function getMinHits() - { - return $this->container['minHits'] ?? null; - } - - /** - * Sets minHits - * - * @param int $minHits Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. - * - * @return self - */ - public function setMinHits($minHits) - { - $this->container['minHits'] = $minHits; - - return $this; - } - - /** - * Gets minLetters - * - * @return int - */ - public function getMinLetters() - { - return $this->container['minLetters'] ?? null; - } - - /** - * Sets minLetters - * - * @param int $minLetters minimum number of required letters for a suggestion to remain - * - * @return self - */ - public function setMinLetters($minLetters) - { - $this->container['minLetters'] = $minLetters; - - return $this; - } - - /** - * Gets generate - * - * @return string[][] - */ - public function getGenerate() - { - return $this->container['generate'] ?? null; - } - - /** - * Sets generate - * - * @param string[][] $generate List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). - * - * @return self - */ - public function setGenerate($generate) - { - $this->container['generate'] = $generate; - - return $this; - } - - /** - * Gets external - * - * @return \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexExternal[] - */ - public function getExternal() - { - return $this->container['external'] ?? null; - } - - /** - * Sets external - * - * @param \Algolia\AlgoliaSearch\Model\QuerySuggestions\SourceIndexExternal[] $external list of external indices to use to generate custom Query Suggestions - * - * @return self - */ - public function setExternal($external) - { - $this->container['external'] = $external; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SucessResponse.php b/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SucessResponse.php deleted file mode 100644 index 0f6e1edf5b..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/QuerySuggestions/SucessResponse.php +++ /dev/null @@ -1,253 +0,0 @@ - 'int', - 'message' => 'string', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'status' => null, - 'message' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'status' => 'setStatus', - 'message' => 'setMessage', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'status' => 'getStatus', - 'message' => 'getMessage', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['status'])) { - $this->container['status'] = $data['status']; - } - if (isset($data['message'])) { - $this->container['message'] = $data['message']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['status']) || - $this->container['status'] === null - ) { - $invalidProperties[] = "'status' can't be null"; - } - if ( - !isset($this->container['message']) || - $this->container['message'] === null - ) { - $invalidProperties[] = "'message' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets status - * - * @return int - */ - public function getStatus() - { - return $this->container['status'] ?? null; - } - - /** - * Sets status - * - * @param int $status the status code - * - * @return self - */ - public function setStatus($status) - { - $this->container['status'] = $status; - - return $this; - } - - /** - * Gets message - * - * @return string - */ - public function getMessage() - { - return $this->container['message'] ?? null; - } - - /** - * Sets message - * - * @param string $message message of the response - * - * @return self - */ - public function setMessage($message) - { - $this->container['message'] = $message; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/Indice.php b/clients/algoliasearch-client-php/lib/Model/Search/Indice.php deleted file mode 100644 index 02e64f9cbc..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/Indice.php +++ /dev/null @@ -1,569 +0,0 @@ - 'string', - 'createdAt' => 'string', - 'updatedAt' => 'string', - 'entries' => 'int', - 'dataSize' => 'int', - 'fileSize' => 'int', - 'lastBuildTimeS' => 'int', - 'numberOfPendingTask' => 'int', - 'pendingTask' => 'bool', - 'primary' => 'string', - 'replicas' => 'string[]', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'name' => null, - 'createdAt' => null, - 'updatedAt' => null, - 'entries' => null, - 'dataSize' => null, - 'fileSize' => null, - 'lastBuildTimeS' => null, - 'numberOfPendingTask' => null, - 'pendingTask' => null, - 'primary' => null, - 'replicas' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'name' => 'setName', - 'createdAt' => 'setCreatedAt', - 'updatedAt' => 'setUpdatedAt', - 'entries' => 'setEntries', - 'dataSize' => 'setDataSize', - 'fileSize' => 'setFileSize', - 'lastBuildTimeS' => 'setLastBuildTimeS', - 'numberOfPendingTask' => 'setNumberOfPendingTask', - 'pendingTask' => 'setPendingTask', - 'primary' => 'setPrimary', - 'replicas' => 'setReplicas', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'name' => 'getName', - 'createdAt' => 'getCreatedAt', - 'updatedAt' => 'getUpdatedAt', - 'entries' => 'getEntries', - 'dataSize' => 'getDataSize', - 'fileSize' => 'getFileSize', - 'lastBuildTimeS' => 'getLastBuildTimeS', - 'numberOfPendingTask' => 'getNumberOfPendingTask', - 'pendingTask' => 'getPendingTask', - 'primary' => 'getPrimary', - 'replicas' => 'getReplicas', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['name'])) { - $this->container['name'] = $data['name']; - } - if (isset($data['createdAt'])) { - $this->container['createdAt'] = $data['createdAt']; - } - if (isset($data['updatedAt'])) { - $this->container['updatedAt'] = $data['updatedAt']; - } - if (isset($data['entries'])) { - $this->container['entries'] = $data['entries']; - } - if (isset($data['dataSize'])) { - $this->container['dataSize'] = $data['dataSize']; - } - if (isset($data['fileSize'])) { - $this->container['fileSize'] = $data['fileSize']; - } - if (isset($data['lastBuildTimeS'])) { - $this->container['lastBuildTimeS'] = $data['lastBuildTimeS']; - } - if (isset($data['numberOfPendingTask'])) { - $this->container['numberOfPendingTask'] = - $data['numberOfPendingTask']; - } - if (isset($data['pendingTask'])) { - $this->container['pendingTask'] = $data['pendingTask']; - } - if (isset($data['primary'])) { - $this->container['primary'] = $data['primary']; - } - if (isset($data['replicas'])) { - $this->container['replicas'] = $data['replicas']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['name']) || - $this->container['name'] === null - ) { - $invalidProperties[] = "'name' can't be null"; - } - if ( - !isset($this->container['createdAt']) || - $this->container['createdAt'] === null - ) { - $invalidProperties[] = "'createdAt' can't be null"; - } - if ( - !isset($this->container['updatedAt']) || - $this->container['updatedAt'] === null - ) { - $invalidProperties[] = "'updatedAt' can't be null"; - } - if ( - !isset($this->container['entries']) || - $this->container['entries'] === null - ) { - $invalidProperties[] = "'entries' can't be null"; - } - if ( - !isset($this->container['dataSize']) || - $this->container['dataSize'] === null - ) { - $invalidProperties[] = "'dataSize' can't be null"; - } - if ( - !isset($this->container['fileSize']) || - $this->container['fileSize'] === null - ) { - $invalidProperties[] = "'fileSize' can't be null"; - } - if ( - !isset($this->container['lastBuildTimeS']) || - $this->container['lastBuildTimeS'] === null - ) { - $invalidProperties[] = "'lastBuildTimeS' can't be null"; - } - if ( - !isset($this->container['pendingTask']) || - $this->container['pendingTask'] === null - ) { - $invalidProperties[] = "'pendingTask' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets name - * - * @return string - */ - public function getName() - { - return $this->container['name'] ?? null; - } - - /** - * Sets name - * - * @param string $name index name - * - * @return self - */ - public function setName($name) - { - $this->container['name'] = $name; - - return $this; - } - - /** - * Gets createdAt - * - * @return string - */ - public function getCreatedAt() - { - return $this->container['createdAt'] ?? null; - } - - /** - * Sets createdAt - * - * @param string $createdAt Index creation date. An empty string means that the index has no records. - * - * @return self - */ - public function setCreatedAt($createdAt) - { - $this->container['createdAt'] = $createdAt; - - return $this; - } - - /** - * Gets updatedAt - * - * @return string - */ - public function getUpdatedAt() - { - return $this->container['updatedAt'] ?? null; - } - - /** - * Sets updatedAt - * - * @param string $updatedAt date of last update (ISO-8601 format) - * - * @return self - */ - public function setUpdatedAt($updatedAt) - { - $this->container['updatedAt'] = $updatedAt; - - return $this; - } - - /** - * Gets entries - * - * @return int - */ - public function getEntries() - { - return $this->container['entries'] ?? null; - } - - /** - * Sets entries - * - * @param int $entries number of records contained in the index - * - * @return self - */ - public function setEntries($entries) - { - $this->container['entries'] = $entries; - - return $this; - } - - /** - * Gets dataSize - * - * @return int - */ - public function getDataSize() - { - return $this->container['dataSize'] ?? null; - } - - /** - * Sets dataSize - * - * @param int $dataSize number of bytes of the index in minified format - * - * @return self - */ - public function setDataSize($dataSize) - { - $this->container['dataSize'] = $dataSize; - - return $this; - } - - /** - * Gets fileSize - * - * @return int - */ - public function getFileSize() - { - return $this->container['fileSize'] ?? null; - } - - /** - * Sets fileSize - * - * @param int $fileSize number of bytes of the index binary file - * - * @return self - */ - public function setFileSize($fileSize) - { - $this->container['fileSize'] = $fileSize; - - return $this; - } - - /** - * Gets lastBuildTimeS - * - * @return int - */ - public function getLastBuildTimeS() - { - return $this->container['lastBuildTimeS'] ?? null; - } - - /** - * Sets lastBuildTimeS - * - * @param int $lastBuildTimeS last build time - * - * @return self - */ - public function setLastBuildTimeS($lastBuildTimeS) - { - $this->container['lastBuildTimeS'] = $lastBuildTimeS; - - return $this; - } - - /** - * Gets numberOfPendingTask - * - * @return int|null - */ - public function getNumberOfPendingTask() - { - return $this->container['numberOfPendingTask'] ?? null; - } - - /** - * Sets numberOfPendingTask - * - * @param int|null $numberOfPendingTask Number of pending indexing operations. This value is deprecated and should not be used. - * - * @return self - */ - public function setNumberOfPendingTask($numberOfPendingTask) - { - $this->container['numberOfPendingTask'] = $numberOfPendingTask; - - return $this; - } - - /** - * Gets pendingTask - * - * @return bool - */ - public function getPendingTask() - { - return $this->container['pendingTask'] ?? null; - } - - /** - * Sets pendingTask - * - * @param bool $pendingTask A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. - * - * @return self - */ - public function setPendingTask($pendingTask) - { - $this->container['pendingTask'] = $pendingTask; - - return $this; - } - - /** - * Gets primary - * - * @return string|null - */ - public function getPrimary() - { - return $this->container['primary'] ?? null; - } - - /** - * Sets primary - * - * @param string|null $primary Only present if the index is a replica. Contains the name of the related primary index. - * - * @return self - */ - public function setPrimary($primary) - { - $this->container['primary'] = $primary; - - return $this; - } - - /** - * Gets replicas - * - * @return string[]|null - */ - public function getReplicas() - { - return $this->container['replicas'] ?? null; - } - - /** - * Sets replicas - * - * @param string[]|null $replicas Only present if the index is a primary index with replicas. Contains the names of all linked replicas. - * - * @return self - */ - public function setReplicas($replicas) - { - $this->container['replicas'] = $replicas; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} From 22f77f24e591d4abfa80587ddfb1eaf1a97c5e52 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 19 May 2022 14:51:50 +0200 Subject: [PATCH 5/8] chore(ci): close generation comment with last commit (#513) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte --- .github/workflows/check.yml | 1 - .github/workflows/codegen.yml | 6 ++-- scripts/ci/codegen/__tests__/codegen.test.ts | 14 ++++++--- scripts/ci/codegen/cleanGeneratedBranch.ts | 3 +- scripts/ci/codegen/text.ts | 23 ++++++++------- scripts/ci/codegen/upsertGenerationComment.ts | 29 +++++++------------ 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1ba040ab5d..3ad09d5afe 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -316,7 +316,6 @@ jobs: - name: Push generated code id: pushGeneratedCode - if: ${{ needs.setup.outputs.RUN_CODEGEN == 'true' }} run: yarn workspace scripts pushGeneratedCode env: GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }} diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 33a337b484..0cf464513b 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -41,11 +41,11 @@ jobs: with: type: minimal - - name: Clean previously generated branch - run: yarn workspace scripts cleanGeneratedBranch ${{ github.head_ref }} - - name: Add cleanup comment run: yarn workspace scripts upsertGenerationComment cleanup env: GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }} PR_NUMBER: ${{ github.event.number }} + + - name: Clean previously generated branch + run: yarn workspace scripts cleanGeneratedBranch ${{ github.head_ref }} diff --git a/scripts/ci/codegen/__tests__/codegen.test.ts b/scripts/ci/codegen/__tests__/codegen.test.ts index b4aa42c3cc..5ab99b270c 100644 --- a/scripts/ci/codegen/__tests__/codegen.test.ts +++ b/scripts/ci/codegen/__tests__/codegen.test.ts @@ -7,6 +7,11 @@ import { upsertGenerationComment, } from '../upsertGenerationComment'; +jest.mock('../../../common', () => ({ + ...(jest.requireActual('../../../common') as any), + run: jest.fn().mockResolvedValue('mocked'), +})); + describe('codegen', () => { describe('cleanGeneratedBranch', () => { it('throws without parameters', async () => { @@ -51,7 +56,7 @@ describe('codegen', () => { expect(await getCommentBody('notification')).toMatchInlineSnapshot(` "### 🔨 The codegen job will run at the end of the CI. - _Make sure your last commit does not contains generated code, it will be automatically pushed by our CI._" + _Make sure your last commit does not contain generated code, it will be automatically pushed by our CI._" `); }); @@ -67,7 +72,8 @@ describe('codegen', () => { expect(await getCommentBody('cleanup')).toMatchInlineSnapshot(` "### ✗ The generated branch has been deleted. - If the PR has been merged, you can check the generated code on the [\`${MAIN_BRANCH}\` branch](https://github.com/algolia/api-clients-automation/tree/${MAIN_BRANCH})." + If the PR has been merged, you can check the generated code on the [\`${MAIN_BRANCH}\` branch](https://github.com/algolia/api-clients-automation/tree/${MAIN_BRANCH}). + You can still access [the last generated commit](https://github.com/algolia/api-clients-automation/commit/mocked)." `); }); @@ -75,10 +81,10 @@ describe('codegen', () => { it('creates a comment body for the parameters', () => { expect( commentText.codegen.body( + 'theGeneratedCommit', 'myBranch', 'myCommit', - 42, - 'theGeneratedCommit' + 42 ) ).toMatchInlineSnapshot(` " diff --git a/scripts/ci/codegen/cleanGeneratedBranch.ts b/scripts/ci/codegen/cleanGeneratedBranch.ts index c45a4a95f0..252ddbd0a1 100644 --- a/scripts/ci/codegen/cleanGeneratedBranch.ts +++ b/scripts/ci/codegen/cleanGeneratedBranch.ts @@ -26,8 +26,7 @@ export async function cleanGeneratedBranch(headRef: string): Promise { await run(`git push -d origin ${generatedCodeBranch}`); } -const args = process.argv.slice(2); - if (require.main === module) { + const args = process.argv.slice(2); cleanGeneratedBranch(args[0]); } diff --git a/scripts/ci/codegen/text.ts b/scripts/ci/codegen/text.ts index e90f8eb4a3..6ac416e138 100644 --- a/scripts/ci/codegen/text.ts +++ b/scripts/ci/codegen/text.ts @@ -4,31 +4,34 @@ export default { commitStartMessage: 'chore: generated code for commit', notification: { header: '### 🔨 The codegen job will run at the end of the CI.', - body: '_Make sure your last commit does not contains generated code, it will be automatically pushed by our CI._', + body: (): string => + '_Make sure your last commit does not contain generated code, it will be automatically pushed by our CI._', }, noGen: { header: '### ✗ No code generated.', - body: `_If you believe this is an issue on our side, please [open an issue](${REPO_URL}/issues/new?template=Bug_report.md)._`, + body: (): string => + `_If you believe this is an issue on our side, please [open an issue](${REPO_URL}/issues/new?template=Bug_report.md)._`, }, cleanup: { header: '### ✗ The generated branch has been deleted.', - body: `If the PR has been merged, you can check the generated code on the [\`${MAIN_BRANCH}\` branch](${REPO_URL}/tree/${MAIN_BRANCH}).`, + body: ( + generatedCommit: string + ): string => `If the PR has been merged, you can check the generated code on the [\`${MAIN_BRANCH}\` branch](${REPO_URL}/tree/${MAIN_BRANCH}). +You can still access [the last generated commit](${REPO_URL}/commit/${generatedCommit}).`, }, codegen: { header: '### ✔️ Code generated!', - body( + body: ( + generatedCommit: string, branch: string, commit: string, - eventNumber: number, - generatedCommit: string - ): string { - return ` + eventNumber: number + ): string => ` | Name | Link | |---------------------------------|------------------------| | 🔨 Triggered by | [\`${commit}\`](${REPO_URL}/pull/${eventNumber}/commits/${commit}) | | 🔍 Generated code | [\`${generatedCommit}\`](${REPO_URL}/commit/${generatedCommit}) | | 🌲 Generated branch | [\`${branch}\`](${REPO_URL}/tree/${branch}) | -`; - }, +`, }, }; diff --git a/scripts/ci/codegen/upsertGenerationComment.ts b/scripts/ci/codegen/upsertGenerationComment.ts index b5cc7c0009..f2d6c84a7a 100644 --- a/scripts/ci/codegen/upsertGenerationComment.ts +++ b/scripts/ci/codegen/upsertGenerationComment.ts @@ -9,23 +9,16 @@ const PR_NUMBER = parseInt(process.env.PR_NUMBER || '0', 10); const octokit = getOctokit(process.env.GITHUB_TOKEN!); const args = process.argv.slice(2); -const allowedTriggers = ['notification', 'codegen', 'noGen', 'cleanup']; +const allowedTriggers = [ + 'notification', + 'codegen', + 'noGen', + 'cleanup', +] as const; -type Trigger = keyof typeof commentText; +type Trigger = typeof allowedTriggers[number]; export async function getCommentBody(trigger: Trigger): Promise { - // All of the case where we are not pushing generated code. - if ( - trigger === 'notification' || - trigger === 'noGen' || - trigger === 'cleanup' - ) { - return `${commentText[trigger].header} - -${commentText[trigger].body}`; - } - - // We are on a codegen step on a pull request here const generatedBranch = await run('git branch --show-current'); const baseBranch = generatedBranch.replace('generated/', ''); const baseCommit = await run(`git show ${baseBranch} -s --format=%H`); @@ -34,13 +27,13 @@ ${commentText[trigger].body}`; `git show ${generatedBranch} -s --format=%H` ); - return `${commentText.codegen.header} + return `${commentText[trigger].header} -${commentText.codegen.body( +${commentText[trigger].body( + generatedCommit, generatedBranch, baseCommit, - PR_NUMBER, - generatedCommit + PR_NUMBER )}`; } From 0d23c52c6beee1b2447e94ca2a007c28b8689b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Thu, 19 May 2022 15:41:31 +0200 Subject: [PATCH 6/8] fix(specs): rename `search` method (#514) --- .../model/recommend/RequiredSearchParams.java | 62 ---- .../algolia/model/search/MultipleQueries.java | 147 -------- .../model/search/MultipleQueriesParams.java | 91 ----- .../model/search/MultipleQueriesResponse.java | 72 ---- .../model/search/MultipleQueriesStrategy.java | 57 --- .../model/search/MultipleQueriesType.java | 57 --- .../model/search/RequiredSearchParams.java | 62 ---- .../model/multipleQueries.ts | 21 -- .../model/multipleQueriesParams.ts | 7 - .../model/multipleQueriesResponse.ts | 5 - .../model/multipleQueriesStrategy.ts | 1 - .../model/multipleQueriesType.ts | 4 - .../model/requiredSearchParams.ts | 6 - .../client-search/model/multipleQueries.ts | 21 -- .../model/multipleQueriesParams.ts | 7 - .../model/multipleQueriesResponse.ts | 5 - .../model/multipleQueriesStrategy.ts | 1 - .../model/multipleQueriesType.ts | 4 - .../model/requiredSearchParams.ts | 6 - .../recommend/model/requiredSearchParams.ts | 6 - .../Model/Recommend/RequiredSearchParams.php | 216 ----------- .../lib/Model/Search/MultipleQueries.php | 340 ------------------ .../Model/Search/MultipleQueriesParams.php | 247 ------------- .../Model/Search/MultipleQueriesResponse.php | 209 ----------- .../Model/Search/MultipleQueriesStrategy.php | 29 -- .../lib/Model/Search/MultipleQueriesType.php | 31 -- .../lib/Model/Search/RequiredSearchParams.php | 216 ----------- .../java/com/algolia/playground/Search.java | 31 +- playground/javascript/node/search.ts | 8 +- playground/php/src/search.php | 13 +- specs/common/schemas/SearchParams.yml | 10 +- specs/search/common/enums.yml | 4 +- .../search/common/schemas/SearchResponse.yml | 2 +- specs/search/paths/search/multipleQueries.yml | 63 ---- specs/search/paths/search/search.yml | 45 ++- .../search/paths/search/searchSingleIndex.yml | 29 ++ specs/search/spec.yml | 4 +- tests/CTS/client/search/api.json | 21 +- .../requests/search/multipleQueries.json | 68 ---- tests/CTS/methods/requests/search/search.json | 108 ++++-- .../requests/search/searchSingleIndex.json | 41 +++ .../guides/filtering-your-search.mdx | 126 ++++--- .../api-clients/guides/retrieving-facets.mdx | 60 ++-- website/docs/api-clients/installation.mdx | 155 +++++--- website/docs/api-clients/migration-guide.mdx | 42 ++- 45 files changed, 487 insertions(+), 2273 deletions(-) delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RequiredSearchParams.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueries.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesParams.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesResponse.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesStrategy.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesType.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/RequiredSearchParams.java delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueries.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesParams.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesResponse.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesStrategy.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesType.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/requiredSearchParams.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueries.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesParams.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesResponse.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesStrategy.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesType.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/requiredSearchParams.ts delete mode 100644 clients/algoliasearch-client-javascript/packages/recommend/model/requiredSearchParams.ts delete mode 100644 clients/algoliasearch-client-php/lib/Model/Recommend/RequiredSearchParams.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/MultipleQueries.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesParams.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesResponse.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesStrategy.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesType.php delete mode 100644 clients/algoliasearch-client-php/lib/Model/Search/RequiredSearchParams.php delete mode 100644 specs/search/paths/search/multipleQueries.yml create mode 100644 specs/search/paths/search/searchSingleIndex.yml delete mode 100644 tests/CTS/methods/requests/search/multipleQueries.json create mode 100644 tests/CTS/methods/requests/search/searchSingleIndex.json diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RequiredSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RequiredSearchParams.java deleted file mode 100644 index a4780d7ccb..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RequiredSearchParams.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.algolia.model.recommend; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** RequiredSearchParams */ -public class RequiredSearchParams { - - @SerializedName("query") - private String query = ""; - - public RequiredSearchParams setQuery(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RequiredSearchParams requiredSearchParams = (RequiredSearchParams) o; - return Objects.equals(this.query, requiredSearchParams.query); - } - - @Override - public int hashCode() { - return Objects.hash(query); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class RequiredSearchParams {\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueries.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueries.java deleted file mode 100644 index a9b60e02a6..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueries.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** MultipleQueries */ -public class MultipleQueries { - - @SerializedName("indexName") - private String indexName; - - @SerializedName("query") - private String query = ""; - - @SerializedName("type") - private MultipleQueriesType type = MultipleQueriesType.DEFAULT; - - @SerializedName("facet") - private String facet; - - @SerializedName("params") - private String params; - - public MultipleQueries setIndexName(String indexName) { - this.indexName = indexName; - return this; - } - - /** - * The Algolia index name. - * - * @return indexName - */ - @javax.annotation.Nonnull - public String getIndexName() { - return indexName; - } - - public MultipleQueries setQuery(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nullable - public String getQuery() { - return query; - } - - public MultipleQueries setType(MultipleQueriesType type) { - this.type = type; - return this; - } - - /** - * Get type - * - * @return type - */ - @javax.annotation.Nullable - public MultipleQueriesType getType() { - return type; - } - - public MultipleQueries setFacet(String facet) { - this.facet = facet; - return this; - } - - /** - * The `facet` name. - * - * @return facet - */ - @javax.annotation.Nullable - public String getFacet() { - return facet; - } - - public MultipleQueries setParams(String params) { - this.params = params; - return this; - } - - /** - * A query string of search parameters. - * - * @return params - */ - @javax.annotation.Nullable - public String getParams() { - return params; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MultipleQueries multipleQueries = (MultipleQueries) o; - return ( - Objects.equals(this.indexName, multipleQueries.indexName) && - Objects.equals(this.query, multipleQueries.query) && - Objects.equals(this.type, multipleQueries.type) && - Objects.equals(this.facet, multipleQueries.facet) && - Objects.equals(this.params, multipleQueries.params) - ); - } - - @Override - public int hashCode() { - return Objects.hash(indexName, query, type, facet, params); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MultipleQueries {\n"); - sb - .append(" indexName: ") - .append(toIndentedString(indexName)) - .append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" facet: ").append(toIndentedString(facet)).append("\n"); - sb.append(" params: ").append(toIndentedString(params)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesParams.java deleted file mode 100644 index d7de433462..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesParams.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** MultipleQueriesParams */ -public class MultipleQueriesParams { - - @SerializedName("requests") - private List requests = new ArrayList<>(); - - @SerializedName("strategy") - private MultipleQueriesStrategy strategy; - - public MultipleQueriesParams setRequests(List requests) { - this.requests = requests; - return this; - } - - public MultipleQueriesParams addRequests(MultipleQueries requestsItem) { - this.requests.add(requestsItem); - return this; - } - - /** - * Get requests - * - * @return requests - */ - @javax.annotation.Nonnull - public List getRequests() { - return requests; - } - - public MultipleQueriesParams setStrategy(MultipleQueriesStrategy strategy) { - this.strategy = strategy; - return this; - } - - /** - * Get strategy - * - * @return strategy - */ - @javax.annotation.Nullable - public MultipleQueriesStrategy getStrategy() { - return strategy; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MultipleQueriesParams multipleQueriesParams = (MultipleQueriesParams) o; - return ( - Objects.equals(this.requests, multipleQueriesParams.requests) && - Objects.equals(this.strategy, multipleQueriesParams.strategy) - ); - } - - @Override - public int hashCode() { - return Objects.hash(requests, strategy); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MultipleQueriesParams {\n"); - sb.append(" requests: ").append(toIndentedString(requests)).append("\n"); - sb.append(" strategy: ").append(toIndentedString(strategy)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesResponse.java deleted file mode 100644 index c6e72805f2..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesResponse.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** MultipleQueriesResponse */ -public class MultipleQueriesResponse { - - @SerializedName("results") - private List results = null; - - public MultipleQueriesResponse setResults(List results) { - this.results = results; - return this; - } - - public MultipleQueriesResponse addResults(SearchResponse resultsItem) { - if (this.results == null) { - this.results = new ArrayList<>(); - } - this.results.add(resultsItem); - return this; - } - - /** - * Get results - * - * @return results - */ - @javax.annotation.Nullable - public List getResults() { - return results; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MultipleQueriesResponse multipleQueriesResponse = (MultipleQueriesResponse) o; - return Objects.equals(this.results, multipleQueriesResponse.results); - } - - @Override - public int hashCode() { - return Objects.hash(results); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class MultipleQueriesResponse {\n"); - sb.append(" results: ").append(toIndentedString(results)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesStrategy.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesStrategy.java deleted file mode 100644 index 446e340f26..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesStrategy.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -/** Gets or Sets multipleQueriesStrategy */ -@JsonAdapter(MultipleQueriesStrategy.Adapter.class) -public enum MultipleQueriesStrategy { - NONE("none"), - - STOP_IF_ENOUGH_MATCHES("stopIfEnoughMatches"); - - private final String value; - - MultipleQueriesStrategy(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static MultipleQueriesStrategy fromValue(String value) { - for (MultipleQueriesStrategy b : MultipleQueriesStrategy.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final MultipleQueriesStrategy enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public MultipleQueriesStrategy read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return MultipleQueriesStrategy.fromValue(value); - } - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesType.java deleted file mode 100644 index c08f3139f0..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/MultipleQueriesType.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; - -/** Perform a search query with `default`, will search for facet values if `facet` is given. */ -@JsonAdapter(MultipleQueriesType.Adapter.class) -public enum MultipleQueriesType { - DEFAULT("default"), - - FACET("facet"); - - private final String value; - - MultipleQueriesType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static MultipleQueriesType fromValue(String value) { - for (MultipleQueriesType b : MultipleQueriesType.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final MultipleQueriesType enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public MultipleQueriesType read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return MultipleQueriesType.fromValue(value); - } - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/RequiredSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/RequiredSearchParams.java deleted file mode 100644 index d94b3d223f..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/RequiredSearchParams.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** RequiredSearchParams */ -public class RequiredSearchParams { - - @SerializedName("query") - private String query = ""; - - public RequiredSearchParams setQuery(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RequiredSearchParams requiredSearchParams = (RequiredSearchParams) o; - return Objects.equals(this.query, requiredSearchParams.query); - } - - @Override - public int hashCode() { - return Objects.hash(query); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class RequiredSearchParams {\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueries.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueries.ts deleted file mode 100644 index 1096b0c8fa..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueries.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { MultipleQueriesType } from './multipleQueriesType'; - -export type MultipleQueries = { - /** - * The Algolia index name. - */ - indexName: string; - /** - * The text to search in the index. - */ - query?: string; - type?: MultipleQueriesType; - /** - * The `facet` name. - */ - facet?: string; - /** - * A query string of search parameters. - */ - params?: string; -}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesParams.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesParams.ts deleted file mode 100644 index eef22ed29f..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesParams.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { MultipleQueries } from './multipleQueries'; -import type { MultipleQueriesStrategy } from './multipleQueriesStrategy'; - -export type MultipleQueriesParams = { - requests: MultipleQueries[]; - strategy?: MultipleQueriesStrategy; -}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesResponse.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesResponse.ts deleted file mode 100644 index 7d96feba7b..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesResponse.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { SearchResponse } from './searchResponse'; - -export type MultipleQueriesResponse = { - results?: SearchResponse[]; -}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesStrategy.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesStrategy.ts deleted file mode 100644 index 5090359e8e..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesStrategy.ts +++ /dev/null @@ -1 +0,0 @@ -export type MultipleQueriesStrategy = 'none' | 'stopIfEnoughMatches'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesType.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesType.ts deleted file mode 100644 index 470705f633..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/multipleQueriesType.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Perform a search query with `default`, will search for facet values if `facet` is given. - */ -export type MultipleQueriesType = 'default' | 'facet'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/requiredSearchParams.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/requiredSearchParams.ts deleted file mode 100644 index 411ca99b94..0000000000 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/requiredSearchParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type RequiredSearchParams = { - /** - * The text to search in the index. - */ - query: string; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueries.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueries.ts deleted file mode 100644 index 1096b0c8fa..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueries.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { MultipleQueriesType } from './multipleQueriesType'; - -export type MultipleQueries = { - /** - * The Algolia index name. - */ - indexName: string; - /** - * The text to search in the index. - */ - query?: string; - type?: MultipleQueriesType; - /** - * The `facet` name. - */ - facet?: string; - /** - * A query string of search parameters. - */ - params?: string; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesParams.ts deleted file mode 100644 index eef22ed29f..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesParams.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { MultipleQueries } from './multipleQueries'; -import type { MultipleQueriesStrategy } from './multipleQueriesStrategy'; - -export type MultipleQueriesParams = { - requests: MultipleQueries[]; - strategy?: MultipleQueriesStrategy; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesResponse.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesResponse.ts deleted file mode 100644 index 7d96feba7b..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesResponse.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { SearchResponse } from './searchResponse'; - -export type MultipleQueriesResponse = { - results?: SearchResponse[]; -}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesStrategy.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesStrategy.ts deleted file mode 100644 index 5090359e8e..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesStrategy.ts +++ /dev/null @@ -1 +0,0 @@ -export type MultipleQueriesStrategy = 'none' | 'stopIfEnoughMatches'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesType.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesType.ts deleted file mode 100644 index 470705f633..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/multipleQueriesType.ts +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Perform a search query with `default`, will search for facet values if `facet` is given. - */ -export type MultipleQueriesType = 'default' | 'facet'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/requiredSearchParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/requiredSearchParams.ts deleted file mode 100644 index 411ca99b94..0000000000 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/requiredSearchParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type RequiredSearchParams = { - /** - * The text to search in the index. - */ - query: string; -}; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/requiredSearchParams.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/requiredSearchParams.ts deleted file mode 100644 index 411ca99b94..0000000000 --- a/clients/algoliasearch-client-javascript/packages/recommend/model/requiredSearchParams.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type RequiredSearchParams = { - /** - * The text to search in the index. - */ - query: string; -}; diff --git a/clients/algoliasearch-client-php/lib/Model/Recommend/RequiredSearchParams.php b/clients/algoliasearch-client-php/lib/Model/Recommend/RequiredSearchParams.php deleted file mode 100644 index 033771d005..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Recommend/RequiredSearchParams.php +++ /dev/null @@ -1,216 +0,0 @@ - 'string', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'query' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'query' => 'setQuery', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'query' => 'getQuery', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['query']) || - $this->container['query'] === null - ) { - $invalidProperties[] = "'query' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets query - * - * @return string - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueries.php b/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueries.php deleted file mode 100644 index 6dfea55f00..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueries.php +++ /dev/null @@ -1,340 +0,0 @@ - 'string', - 'query' => 'string', - 'type' => '\Algolia\AlgoliaSearch\Model\Search\MultipleQueriesType', - 'facet' => 'string', - 'params' => 'string', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'indexName' => null, - 'query' => null, - 'type' => null, - 'facet' => null, - 'params' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'indexName' => 'setIndexName', - 'query' => 'setQuery', - 'type' => 'setType', - 'facet' => 'setFacet', - 'params' => 'setParams', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'indexName' => 'getIndexName', - 'query' => 'getQuery', - 'type' => 'getType', - 'facet' => 'getFacet', - 'params' => 'getParams', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['indexName'])) { - $this->container['indexName'] = $data['indexName']; - } - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } - if (isset($data['type'])) { - $this->container['type'] = $data['type']; - } - if (isset($data['facet'])) { - $this->container['facet'] = $data['facet']; - } - if (isset($data['params'])) { - $this->container['params'] = $data['params']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['indexName']) || - $this->container['indexName'] === null - ) { - $invalidProperties[] = "'indexName' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets indexName - * - * @return string - */ - public function getIndexName() - { - return $this->container['indexName'] ?? null; - } - - /** - * Sets indexName - * - * @param string $indexName the Algolia index name - * - * @return self - */ - public function setIndexName($indexName) - { - $this->container['indexName'] = $indexName; - - return $this; - } - - /** - * Gets query - * - * @return string|null - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string|null $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - - /** - * Gets type - * - * @return \Algolia\AlgoliaSearch\Model\Search\MultipleQueriesType|null - */ - public function getType() - { - return $this->container['type'] ?? null; - } - - /** - * Sets type - * - * @param \Algolia\AlgoliaSearch\Model\Search\MultipleQueriesType|null $type type - * - * @return self - */ - public function setType($type) - { - $this->container['type'] = $type; - - return $this; - } - - /** - * Gets facet - * - * @return string|null - */ - public function getFacet() - { - return $this->container['facet'] ?? null; - } - - /** - * Sets facet - * - * @param string|null $facet the `facet` name - * - * @return self - */ - public function setFacet($facet) - { - $this->container['facet'] = $facet; - - return $this; - } - - /** - * Gets params - * - * @return string|null - */ - public function getParams() - { - return $this->container['params'] ?? null; - } - - /** - * Sets params - * - * @param string|null $params a query string of search parameters - * - * @return self - */ - public function setParams($params) - { - $this->container['params'] = $params; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesParams.php b/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesParams.php deleted file mode 100644 index 3b34125292..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesParams.php +++ /dev/null @@ -1,247 +0,0 @@ - '\Algolia\AlgoliaSearch\Model\Search\MultipleQueries[]', - 'strategy' => '\Algolia\AlgoliaSearch\Model\Search\MultipleQueriesStrategy', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'requests' => null, - 'strategy' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'requests' => 'setRequests', - 'strategy' => 'setStrategy', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'requests' => 'getRequests', - 'strategy' => 'getStrategy', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['requests'])) { - $this->container['requests'] = $data['requests']; - } - if (isset($data['strategy'])) { - $this->container['strategy'] = $data['strategy']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['requests']) || - $this->container['requests'] === null - ) { - $invalidProperties[] = "'requests' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets requests - * - * @return \Algolia\AlgoliaSearch\Model\Search\MultipleQueries[] - */ - public function getRequests() - { - return $this->container['requests'] ?? null; - } - - /** - * Sets requests - * - * @param \Algolia\AlgoliaSearch\Model\Search\MultipleQueries[] $requests requests - * - * @return self - */ - public function setRequests($requests) - { - $this->container['requests'] = $requests; - - return $this; - } - - /** - * Gets strategy - * - * @return \Algolia\AlgoliaSearch\Model\Search\MultipleQueriesStrategy|null - */ - public function getStrategy() - { - return $this->container['strategy'] ?? null; - } - - /** - * Sets strategy - * - * @param \Algolia\AlgoliaSearch\Model\Search\MultipleQueriesStrategy|null $strategy strategy - * - * @return self - */ - public function setStrategy($strategy) - { - $this->container['strategy'] = $strategy; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesResponse.php b/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesResponse.php deleted file mode 100644 index 29d66d17a3..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesResponse.php +++ /dev/null @@ -1,209 +0,0 @@ - '\Algolia\AlgoliaSearch\Model\Search\SearchResponse[]', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'results' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'results' => 'setResults', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'results' => 'getResults', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['results'])) { - $this->container['results'] = $data['results']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets results - * - * @return \Algolia\AlgoliaSearch\Model\Search\SearchResponse[]|null - */ - public function getResults() - { - return $this->container['results'] ?? null; - } - - /** - * Sets results - * - * @param \Algolia\AlgoliaSearch\Model\Search\SearchResponse[]|null $results results - * - * @return self - */ - public function setResults($results) - { - $this->container['results'] = $results; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesStrategy.php b/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesStrategy.php deleted file mode 100644 index 216d07cab3..0000000000 --- a/clients/algoliasearch-client-php/lib/Model/Search/MultipleQueriesStrategy.php +++ /dev/null @@ -1,29 +0,0 @@ - 'string', - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $modelFormats = [ - 'query' => null, - ]; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function modelTypes() - { - return self::$modelTypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function modelFormats() - { - return self::$modelFormats; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'query' => 'setQuery', - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'query' => 'getQuery', - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - */ - public function __construct(array $data = null) - { - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ( - !isset($this->container['query']) || - $this->container['query'] === null - ) { - $invalidProperties[] = "'query' can't be null"; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - /** - * Gets query - * - * @return string - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param int $offset Offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param int $offset Offset - * - * @return mixed|null - */ - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param int $offset Offset - * - * @return void - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} diff --git a/playground/java/src/main/java/com/algolia/playground/Search.java b/playground/java/src/main/java/com/algolia/playground/Search.java index b1b93726c9..f8bc911af3 100644 --- a/playground/java/src/main/java/com/algolia/playground/Search.java +++ b/playground/java/src/main/java/com/algolia/playground/Search.java @@ -1,18 +1,19 @@ package com.algolia.playground; +import com.algolia.api.SearchClient; import com.algolia.exceptions.AlgoliaApiException; import com.algolia.exceptions.AlgoliaRetryException; import com.algolia.exceptions.AlgoliaRuntimeException; import com.algolia.model.search.*; -import com.algolia.api.SearchClient; import com.algolia.utils.AlgoliaAgent; import io.github.cdimascio.dotenv.Dotenv; +import java.lang.InterruptedException; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.lang.InterruptedException; public class Search { - + public static void main(String[] args) { Dotenv dotenv = Dotenv.configure().directory("../").load(); @@ -27,21 +28,27 @@ public static void main(String[] args) { ); String indexName = dotenv.get("SEARCH_INDEX"); - SearchParamsObject params = new SearchParamsObject(); - params.setAroundRadius(AroundRadius.ofInteger(5)); - params.setQuery(dotenv.get("SEARCH_QUERY")); + String query = dotenv.get("SEARCH_QUERY"); try { - CompletableFuture result = client.searchAsync( - indexName, - SearchParams.ofSearchParamsObject(params) + SearchMethodParams searchMethodParams = new SearchMethodParams(); + List requests = new ArrayList<>(); + SearchQueries request = new SearchQueries(); + request.setIndexName(indexName); + request.setQuery(query); + requests.add(request); + searchMethodParams.setRequests(requests); + + CompletableFuture result = client.searchAsync( + searchMethodParams ); - SearchResponse sr = result.get(); + + SearchResponses sr = result.get(); System.out.println(sr); - } catch(InterruptedException e) { + } catch (InterruptedException e) { System.err.println("InterrupedException" + e.getMessage()); e.printStackTrace(); - } catch(ExecutionException e) { + } catch (ExecutionException e) { System.err.println("ExecutionException" + e.getMessage()); e.printStackTrace(); } catch (AlgoliaApiException e) { diff --git a/playground/javascript/node/search.ts b/playground/javascript/node/search.ts index 3f77099c0d..433c475de0 100644 --- a/playground/javascript/node/search.ts +++ b/playground/javascript/node/search.ts @@ -18,8 +18,12 @@ client.addAlgoliaAgent('Node playground', '0.0.1'); async function testSearch() { try { const res = await client.search({ - indexName: searchIndex, - searchParams: { query: searchQuery }, + requests: [ + { + indexName: searchIndex, + query: searchQuery, + }, + ], }); console.log(`[OK]`, res); diff --git a/playground/php/src/search.php b/playground/php/src/search.php index 3c4556e838..685e6305c2 100644 --- a/playground/php/src/search.php +++ b/playground/php/src/search.php @@ -4,7 +4,16 @@ use Algolia\AlgoliaSearch\Api\SearchClient; -$client = SearchClient::create(getenv('ALGOLIA_APPLICATION_ID'), getenv('ALGOLIA_ADMIN_KEY')); +$client = SearchClient::create( + getenv('ALGOLIA_APPLICATION_ID'), + getenv('ALGOLIA_ADMIN_KEY') +); $indexName = getenv('SEARCH_INDEX'); -var_dump($client->search($indexName, ['query' => getenv('SEARCH_QUERY')])); +var_dump( + $client->search([ + 'requests' => [ + ['indexName' => $indexName, 'query' => getenv('SEARCH_QUERY')], + ], + ]) +); diff --git a/specs/common/schemas/SearchParams.yml b/specs/common/schemas/SearchParams.yml index d83e550b5c..dd206ee9be 100644 --- a/specs/common/schemas/SearchParams.yml +++ b/specs/common/schemas/SearchParams.yml @@ -6,22 +6,14 @@ searchParams: searchParamsObject: allOf: - $ref: '#/baseSearchParams' - - $ref: '#/requiredSearchParams' - $ref: '../../common/schemas/IndexSettings.yml#/indexSettingsAsSearchParams' -requiredSearchParams: +baseSearchParams: type: object additionalProperties: false - required: - - query properties: query: $ref: '#/query' - -baseSearchParams: - type: object - additionalProperties: false - properties: similarQuery: type: string description: Overrides the query parameter and performs a more generic search that can be used to find "similar" results. diff --git a/specs/search/common/enums.yml b/specs/search/common/enums.yml index 71574ed674..8ed8cbcdec 100644 --- a/specs/search/common/enums.yml +++ b/specs/search/common/enums.yml @@ -1,10 +1,10 @@ -multipleQueriesType: +searchType: type: string enum: [default, facet] default: default description: Perform a search query with `default`, will search for facet values if `facet` is given. -multipleQueriesStrategy: +searchStrategy: type: string enum: [none, stopIfEnoughMatches] diff --git a/specs/search/common/schemas/SearchResponse.yml b/specs/search/common/schemas/SearchResponse.yml index 2ff61ba1f8..d4c0385963 100644 --- a/specs/search/common/schemas/SearchResponse.yml +++ b/specs/search/common/schemas/SearchResponse.yml @@ -1,4 +1,4 @@ -searchResponse: +SearchResponse: allOf: - $ref: '#/baseSearchResponse' - $ref: '#/searchHits' diff --git a/specs/search/paths/search/multipleQueries.yml b/specs/search/paths/search/multipleQueries.yml deleted file mode 100644 index 049d504b24..0000000000 --- a/specs/search/paths/search/multipleQueries.yml +++ /dev/null @@ -1,63 +0,0 @@ -post: - tags: - - Search - operationId: multipleQueries - summary: Search multiple indices. - description: Perform a search operation targeting one or many indices. - requestBody: - required: true - description: The `multipleQueries` requests and strategy. - content: - application/json: - schema: - title: multipleQueriesParams - type: object - additionalProperties: false - properties: - requests: - type: array - items: - title: multipleQueries - type: object - additionalProperties: false - properties: - indexName: - $ref: '../../../common/parameters.yml#/indexName' - query: - $ref: '../../../common/schemas/SearchParams.yml#/query' - type: - $ref: '../../common/enums.yml#/multipleQueriesType' - facet: - type: string - description: The `facet` name. - params: - type: string - description: A query string of search parameters. - required: - - indexName - strategy: - $ref: '../../common/enums.yml#/multipleQueriesStrategy' - required: - - requests - responses: - '200': - description: OK - content: - application/json: - schema: - title: multipleQueriesResponse - type: object - additionalProperties: false - properties: - results: - type: array - items: - $ref: '../../common/schemas/SearchResponse.yml#/searchResponse' - '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/search/search.yml b/specs/search/paths/search/search.yml index 977cea7184..7aac6b594a 100644 --- a/specs/search/paths/search/search.yml +++ b/specs/search/paths/search/search.yml @@ -2,23 +2,56 @@ post: tags: - Search operationId: search - summary: Search in an index. - description: Perform a search operation targeting one specific index. - parameters: - - $ref: '../../../common/parameters.yml#/IndexName' + summary: Search multiple indices. + description: Perform a search operation targeting one or many indices. requestBody: required: true + description: The `search` requests and strategy. content: application/json: schema: - $ref: '../../../common/schemas/SearchParams.yml#/searchParams' + title: searchMethodParams + type: object + additionalProperties: false + properties: + requests: + type: array + items: + title: searchQueries + type: object + additionalProperties: false + properties: + indexName: + $ref: '../../../common/parameters.yml#/indexName' + query: + $ref: '../../../common/schemas/SearchParams.yml#/query' + type: + $ref: '../../common/enums.yml#/searchType' + facet: + type: string + description: The `facet` name. + params: + $ref: '../../../common/schemas/SearchParams.yml#/searchParams' + required: + - indexName + strategy: + $ref: '../../common/enums.yml#/searchStrategy' + required: + - requests responses: '200': description: OK content: application/json: schema: - $ref: '../../common/schemas/SearchResponse.yml#/searchResponse' + title: searchResponses + type: object + additionalProperties: false + properties: + results: + type: array + items: + $ref: '../../common/schemas/SearchResponse.yml#/SearchResponse' '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/specs/search/paths/search/searchSingleIndex.yml b/specs/search/paths/search/searchSingleIndex.yml new file mode 100644 index 0000000000..104ff5bcdb --- /dev/null +++ b/specs/search/paths/search/searchSingleIndex.yml @@ -0,0 +1,29 @@ +post: + tags: + - Search + operationId: searchSingleIndex + summary: Search in a single index. + description: Perform a search operation targeting one specific index. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + requestBody: + required: true + content: + application/json: + schema: + $ref: '../../../common/schemas/SearchParams.yml#/searchParams' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '../../common/schemas/SearchResponse.yml#/SearchResponse' + '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 7de5efc04d..b9ad4c1f99 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -89,9 +89,9 @@ paths: # ### Search Endpoints ### # ######################## /1/indexes/{indexName}/query: - $ref: 'paths/search/search.yml' + $ref: 'paths/search/searchSingleIndex.yml' /1/indexes/*/queries: - $ref: 'paths/search/multipleQueries.yml' + $ref: 'paths/search/search.yml' /1/indexes/{indexName}/facets/{facetName}/query: $ref: 'paths/search/searchForFacetValues.yml' /1/indexes/{indexName}/browse: diff --git a/tests/CTS/client/search/api.json b/tests/CTS/client/search/api.json index 83c38f3fed..daf1358dc0 100644 --- a/tests/CTS/client/search/api.json +++ b/tests/CTS/client/search/api.json @@ -8,8 +8,11 @@ "path": "search", "parameters": [ { - "indexName": "my-index", - "searchParams": {} + "requests": [ + { + "indexName": "my-index" + } + ] } ], "expected": { @@ -31,8 +34,11 @@ "path": "search", "parameters": [ { - "indexName": "my-index", - "searchParams": {} + "requests": [ + { + "indexName": "my-index" + } + ] } ], "expected": { @@ -53,8 +59,11 @@ "path": "search", "parameters": [ { - "indexName": "my-index", - "searchParams": {} + "requests": [ + { + "indexName": "my-index" + } + ] } ], "expected": { diff --git a/tests/CTS/methods/requests/search/multipleQueries.json b/tests/CTS/methods/requests/search/multipleQueries.json deleted file mode 100644 index f73c4713a7..0000000000 --- a/tests/CTS/methods/requests/search/multipleQueries.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - { - "testName": "multipleQueries for a single request with minimal parameters", - "parameters": { - "requests": [ - { - "indexName": "theIndexName" - } - ], - "strategy": "stopIfEnoughMatches" - }, - "request": { - "path": "/1/indexes/*/queries", - "method": "POST", - "body": { - "requests": [ - { - "indexName": "theIndexName" - } - ], - "strategy": "stopIfEnoughMatches" - } - } - }, - { - "testName": "multipleQueries for multiple requests with all parameters", - "parameters": { - "requests": [ - { - "indexName": "theIndexName", - "query": "test", - "type": "facet", - "facet": "theFacet", - "params": "testParam" - }, - { - "indexName": "theIndexName", - "query": "test", - "type": "default", - "params": "testParam" - } - ], - "strategy": "stopIfEnoughMatches" - }, - "request": { - "path": "/1/indexes/*/queries", - "method": "POST", - "body": { - "requests": [ - { - "indexName": "theIndexName", - "query": "test", - "type": "facet", - "facet": "theFacet", - "params": "testParam" - }, - { - "indexName": "theIndexName", - "query": "test", - "type": "default", - "params": "testParam" - } - ], - "strategy": "stopIfEnoughMatches" - } - } - } -] diff --git a/tests/CTS/methods/requests/search/search.json b/tests/CTS/methods/requests/search/search.json index cb550a42d8..57eb132fb8 100644 --- a/tests/CTS/methods/requests/search/search.json +++ b/tests/CTS/methods/requests/search/search.json @@ -1,40 +1,108 @@ [ { - "testName": "search with minimal parameters", + "testName": "search for a single request with minimal parameters", "parameters": { - "indexName": "indexName", - "searchParams": { - "query": "myQuery" - } + "requests": [ + { + "indexName": "theIndexName" + } + ] }, "request": { - "path": "/1/indexes/indexName/query", + "path": "/1/indexes/*/queries", "method": "POST", "body": { - "query": "myQuery" + "requests": [ + { + "indexName": "theIndexName" + } + ] } } }, { - "method": "search", - "testName": "search with facetFilters", + "testName": "search for a single request with all parameters", "parameters": { - "indexName": "indexName", - "searchParams": { - "query": "myQuery", - "facetFilters": [ - "tags:algolia" - ] + "requests": [ + { + "indexName": "theIndexName", + "query": "test", + "type": "facet", + "facet": "theFacet", + "params": { + "hitsPerPage": 50 + } + } + ], + "strategy": "stopIfEnoughMatches" + }, + "request": { + "path": "/1/indexes/*/queries", + "method": "POST", + "body": { + "requests": [ + { + "indexName": "theIndexName", + "query": "test", + "type": "facet", + "facet": "theFacet", + "params": { + "hitsPerPage": 50 + } + } + ], + "strategy": "stopIfEnoughMatches" } + } + }, + { + "testName": "search for multiple requests in multiple indices with all parameters", + "parameters": { + "requests": [ + { + "indexName": "theIndexName", + "query": "test", + "type": "facet", + "facet": "theFacet", + "params": { + "hitsPerPage": 50 + } + }, + { + "indexName": "theIndexName2", + "query": "test", + "type": "default", + "params": { + "hitsPerPage": 100 + } + } + ], + "strategy": "stopIfEnoughMatches" }, "request": { - "path": "/1/indexes/indexName/query", + "path": "/1/indexes/*/queries", "method": "POST", "body": { - "query": "myQuery", - "facetFilters": [ - "tags:algolia" - ] + "requests": [ + { + "indexName": "theIndexName", + "query": "test", + "type": "facet", + "facet": "theFacet", + "params": { + "hitsPerPage": 50 + } + }, + { + "indexName": "theIndexName2", + "query": "test", + "type": "default", + "params": { + "hitsPerPage": 100 + } + } + ], + "strategy": "stopIfEnoughMatches" } } } diff --git a/tests/CTS/methods/requests/search/searchSingleIndex.json b/tests/CTS/methods/requests/search/searchSingleIndex.json new file mode 100644 index 0000000000..cb550a42d8 --- /dev/null +++ b/tests/CTS/methods/requests/search/searchSingleIndex.json @@ -0,0 +1,41 @@ +[ + { + "testName": "search with minimal parameters", + "parameters": { + "indexName": "indexName", + "searchParams": { + "query": "myQuery" + } + }, + "request": { + "path": "/1/indexes/indexName/query", + "method": "POST", + "body": { + "query": "myQuery" + } + } + }, + { + "method": "search", + "testName": "search with facetFilters", + "parameters": { + "indexName": "indexName", + "searchParams": { + "query": "myQuery", + "facetFilters": [ + "tags:algolia" + ] + } + }, + "request": { + "path": "/1/indexes/indexName/query", + "method": "POST", + "body": { + "query": "myQuery", + "facetFilters": [ + "tags:algolia" + ] + } + } + } +] diff --git a/website/docs/api-clients/guides/filtering-your-search.mdx b/website/docs/api-clients/guides/filtering-your-search.mdx index 180aff3fed..be3bfdaf31 100644 --- a/website/docs/api-clients/guides/filtering-your-search.mdx +++ b/website/docs/api-clients/guides/filtering-your-search.mdx @@ -45,6 +45,7 @@ $client->setSettings( ['attributesForFaceting' => ['actor', 'filterOnly(category)', 'searchable(publisher)']] ); ``` + @@ -67,29 +68,41 @@ The actual filtering of records is performed at query time, not at indexing time ```js // Only "Scarlett Johansson" actor await client.search({ - indexName: '', - searchParams: { - query: '', - filters: 'actor:Scarlett Johansson', - }, + requests: [ + { + indexName: '', + query: '', + params: { + filters: 'actor:Scarlett Johansson', + }, + }, + ], }); // Only "Tom Cruise" or "Scarlett Johansson" actor await client.search({ - indexName: '', - searchParams: { - query: '', - filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', - }, + requests: [ + { + indexName: '', + query: '', + params: { + filters: 'actor:Tom Cruise OR actor:Scarlett Johansson', + }, + }, + ], }); // Everything but "Nicolas Cage" actor await client.search({ - indexName: '', - searchParams: { - query: '', - filters: 'NOT actor:Nicolas Cage', - }, + requests: [ + { + indexName: '', + query: '', + params: { + filters: 'NOT actor:Nicolas Cage', + }, + }, + ], }); ``` @@ -98,33 +111,39 @@ await client.search({ ```php // Only "Scarlett Johansson" actor -$client->search( - '', - [ - 'query' => '', - 'filters' => 'actor:Scarlett Johansson', - ] -); +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['filters' => 'actor:Scarlett Johansson'], + ], + ], +]); // Only "Tom Cruise" or "Scarlett Johansson" actor -$client->search( - '', - [ - 'query' => '', - 'filters' => 'actor:Tom Cruise OR actor:Scarlett Johansson', - ] -); +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['filters' => 'actor:Tom Cruise OR actor:Scarlett Johansson'], + ], + ], +]); // Everything but "Nicolas Cage" actor -$client->search( - '', - [ - 'query' => '', - 'filters' => 'NOT actor:Nicolas Cage', - ] -); - +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['filters' => 'NOT actor:Nicolas Cage'], + ], + ], +]); ``` + @@ -165,22 +184,27 @@ await client.search({ ```php // Only "Scarlett Johansson" actor -$client->search( - '', - [ - 'query' => '', - 'facetFilters' => ['actor:Scarlett Johansson'], - ] -); +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['facetFilters' => ['actor:Scarlett Johansson']], + ], + ], +]); // Only "Tom Cruise" or "Scarlett Johansson" actor -$client->search( - '', - [ - 'query' => '', - 'facetFilters' => ['actor:Tom Cruise', 'actor:Scarlett Johansson'], - ] -); +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['facetFilters' => ['actor:Tom Cruise', 'actor:Scarlett Johansson']], + ], + ], +]); ``` + diff --git a/website/docs/api-clients/guides/retrieving-facets.mdx b/website/docs/api-clients/guides/retrieving-facets.mdx index 6b54580c84..a69293e799 100644 --- a/website/docs/api-clients/guides/retrieving-facets.mdx +++ b/website/docs/api-clients/guides/retrieving-facets.mdx @@ -23,11 +23,15 @@ For example, you can retrieve your books' facets with the `search` method, and t ```js await client.search({ - indexName: '', - searchParams: { - query: '', - facets: ['author', 'genre'], - }, + requests: [ + { + indexName: '', + query: '', + params: { + facets: ['author', 'genre'], + }, + }, + ], }); ``` @@ -35,11 +39,15 @@ To extract all facet information, you can use a wildcard (`*`). ```js await client.search({ - indexName: '', - searchParams: { - query: '', - facets: ['*'], - }, + requests: [ + { + indexName: '', + query: '', + params: { + facets: ['*'], + }, + }, + ], }); ``` @@ -48,25 +56,29 @@ await client.search({ ```php -$client->search( - '', - [ - 'query' => '', - 'facets' => ['author', 'genre'], - ] -); +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['facets' => ['author', 'genre']], + ], + ], +]); ``` To extract all facet information, you can use a wildcard (`*`). ```php -$client->search( - '', - [ - 'query' => '', - 'facets' => ['*'], - ] -); +$client->search([ + 'requests' => [ + [ + 'indexName' => '', + 'query' => '', + 'params' => ['facets' => ['*']], + ], + ], +]); ``` diff --git a/website/docs/api-clients/installation.mdx b/website/docs/api-clients/installation.mdx index 2a33bbfc4b..1d00e5a500 100644 --- a/website/docs/api-clients/installation.mdx +++ b/website/docs/api-clients/installation.mdx @@ -42,8 +42,71 @@ Add the following JavaScript snippet to the `` of your website: ``` + + + + +First, install Algolia PHP API Client via the composer package manager: + +```bash +composer require algolia/algoliasearch-client-php +``` + + + + + +To get started, add the [algoliasearch-client-java](https://oss.sonatype.org/content/repositories/snapshots/com/algolia/algoliasearch-client-java/0.0.1-SNAPSHOT/) dependency to your project, either with [Maven](https://maven.apache.org/): + +```xml + + + oss.sonatype.org-snapshot + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + + + com.algolia + algoliasearch-client-java + 0.0.1-SNAPSHOT + +``` + +or [Gradle](https://gradle.org/): + +```groovy +repositories() { + maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } +} + +dependencies { + testImplementation 'com.algolia:algoliasearch-client-java:0.0.1-SNAPSHOT' +} +``` + + + + ## Using the client + + + Then you need to import the correct package: ```js @@ -60,12 +123,16 @@ const personalizationClient = client.initPersonalization( ); const searchRes = await client.search({ - indexName: '', - searchParams: { query: searchQuery }, + requests: [ + { + indexName: '', + query: '', + }, + ], }); const analyticsRes = await analyticsClient.getTopFilterForAttribute({ attribute: 'myAttribute1,myAttribute2', - index: '', + index: '', }); console.log('[Results]', searchRes, analyticsRes); @@ -96,8 +163,12 @@ Once the client is setup, you can play with the Algolia API! ```js const res = await client.search({ - indexName: '', - searchParams: { query: 'words to query' }, + requests: [ + { + indexName: '', + query: '', + }, + ], }); console.log('[Results]', res); @@ -117,14 +188,6 @@ console.log('[Results]', res); -First, install Algolia PHP API Client via the composer package manager: - -```bash -composer require algolia/algoliasearch-client-php -``` - -## Using the client - Then, create objects on your index: ```php @@ -133,13 +196,17 @@ $client = Algolia\AlgoliaSearch\Api\SearchClient::create( '' ); -$client->saveObject('', ['objectID' => 1, 'name' => 'Foo']); +$client->saveObject('', ['objectID' => 1, 'name' => 'Foo']); ``` Finally, you may begin searching an object using the `search` method: ```php -$objects = $client->search('', ['query' => 'Foo']); +$client->search([ + 'requests' => [ + ['indexName' => '', 'query' => ''], + ], +]) ``` Another example with the personalization client: @@ -157,41 +224,6 @@ $res = $client->getUserTokenProfile(''); -To get started, add the [algoliasearch-client-java](https://oss.sonatype.org/content/repositories/snapshots/com/algolia/algoliasearch-client-java/0.0.1-SNAPSHOT/) dependency to your project, either with [Maven](https://maven.apache.org/): -```xml - - - oss.sonatype.org-snapshot - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - - - - - com.algolia - algoliasearch-client-java - 0.0.1-SNAPSHOT - -``` - -or [Gradle](https://gradle.org/): -```groovy -repositories() { - maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } -} - -dependencies { - testImplementation 'com.algolia:algoliasearch-client-java:0.0.1-SNAPSHOT' -} -``` - -## Using the client - The package is divided into multiples API Clients, you can find the list [here](https://github.com/algolia/algoliasearch-client-java-2/tree/next/algoliasearch-core/src/main/java/com/algolia/api). To instanciate a client, prepare your credentials and follow this example: @@ -199,37 +231,42 @@ To instanciate a client, prepare your credentials and follow this example: import com.algolia.api.SearchClient; public class AlgoliaTest { + public static void main(String[] args) { SearchClient client = new SearchClient("", ""); } } + ``` You can add segments to the `User Agent`: + ```java import com.algolia.utils.AlgoliaAgent; SearchClient client = new SearchClient( - "", + "", "", - new AlgoliaAgent.Segment[] { - new AlgoliaAgent.Segment("tracker", "8.0.0") + new AlgoliaAgent.Segment[] { + new AlgoliaAgent.Segment("tracker", "8.0.0") } ); ``` And also specify a custom `Requester`: + ```java import com.algolia.utils.echo.EchoRequester; SearchClient client = new SearchClient( - "", + "", "", new EchoRequester() ); ``` Or use a completely different client (some clients might require a `region` parameter): + ```java import com.algolia.api.AbtestingClient; @@ -241,13 +278,15 @@ Once the client is setup, you can play with the Algolia API! ```java import com.algolia.model.search.*; -SearchParamsObject params = new SearchParamsObject(); -params.setQuery("your query"); +SearchMethodParams searchMethodParams = new SearchMethodParams(); +SearchQueries requests = new SearchQueries(); +requests.setIndexName(""); +requests.setQuery(""); +searchMethodParams.setRequests(requests); try { SearchResponse result = client.search( - "the index name", - SearchParams.ofSearchParamsObject(params) + searchMethodParams ); System.out.println(result); } catch (AlgoliaRuntimeException e) { diff --git a/website/docs/api-clients/migration-guide.mdx b/website/docs/api-clients/migration-guide.mdx index 72d127ddc0..0f652533b4 100644 --- a/website/docs/api-clients/migration-guide.mdx +++ b/website/docs/api-clients/migration-guide.mdx @@ -38,11 +38,11 @@ For informations regarding the installation of the package, please see [the inst }> -| Previous | Latest | Description | -| -------------------- | :------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `@algolia` | `@experimental-api-clients-automation` | **During the beta phase**, the clients are available under the NPM `@experimental-api-clients-automation` namespace, you can find a full list [here](https://www.npmjs.com/org/experimental-api-clients-automation). | -| `algoliasearch/lite` | `algoliasearch-lite` | The lite version of the client now have [its own package](https://www.npmjs.com/package/@experimental-api-clients-automation/algoliasearch-lite). | -| `search` | `searchClient` | Exported clients are suffixed by `Client`. | +| Previous | Latest | Impacted clients | Description | +| -------------------- | :------------------------------------- | :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `@algolia` | `@experimental-api-clients-automation` | JavaScript | **During the beta phase**, the clients are available under the NPM `@experimental-api-clients-automation` namespace, you can find a full list [here](https://www.npmjs.com/org/experimental-api-clients-automation). | +| `algoliasearch/lite` | `algoliasearch-lite` | JavaScript | The lite version of the client now have [its own package](https://www.npmjs.com/package/@experimental-api-clients-automation/algoliasearch-lite). | +| `search` | `searchClient` | all | Exported clients are suffixed by `Client`. | @@ -51,9 +51,9 @@ For informations regarding the installation of the package, please see [the inst @@ -95,9 +95,9 @@ You can continue this guide on [our installation page](/docs/api-clients/install @@ -111,18 +111,26 @@ const client = algoliasearch('', ''); // only query string const searchResults = await client.search({ - indexName: '', - searchParams: { query: 'myQuery' }, + requests: [ + { + indexName: '', + query: '', + }, + ], }); // with params const searchResults2 = await client.search({ - indexName: '', - searchParams: { - query: 'myQuery', - attributesToRetrieve: ['firstname', 'lastname'], - hitsPerPage: 50, - }, + requests: [ + { + indexName: '', + query: '', + params: { + attributesToRetrieve: ['firstname', 'lastname'], + hitsPerPage: 50, + }, + }, + ], }); ``` From 4bc1931a806fd79c738372f59ea9cd115bbcccd6 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Thu, 19 May 2022 13:52:29 +0000 Subject: [PATCH 7/8] chore: generated code for commit 0d23c52c6beee1b2447e94ca2a007c28b8689b0a. [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte --- .../java/com/algolia/api/SearchClient.java | 216 +++++------ .../model/recommend/BaseSearchParams.java | 21 ++ .../model/recommend/SearchParamsObject.java | 42 +-- .../model/search/BaseSearchParams.java | 21 ++ .../model/search/ConsequenceParams.java | 4 +- .../model/search/SearchMethodParams.java | 91 +++++ .../model/search/SearchParamsObject.java | 42 +-- .../algolia/model/search/SearchQueries.java | 147 ++++++++ .../algolia/model/search/SearchResponses.java | 72 ++++ .../algolia/model/search/SearchStrategy.java | 56 +++ .../com/algolia/model/search/SearchType.java | 56 +++ .../model/baseSearchParams.ts | 4 + .../algoliasearch-lite/model/index.ts | 11 +- .../model/searchMethodParams.ts | 7 + .../model/searchParamsObject.ts | 5 +- .../algoliasearch-lite/model/searchQueries.ts | 19 + .../model/searchResponses.ts | 5 + .../model/searchStrategy.ts | 1 + .../algoliasearch-lite/model/searchType.ts | 4 + .../src/algoliasearchLiteClient.ts | 84 +---- .../client-search/model/baseSearchParams.ts | 4 + .../packages/client-search/model/index.ts | 11 +- .../client-search/model/searchMethodParams.ts | 7 + .../client-search/model/searchParamsObject.ts | 5 +- .../client-search/model/searchQueries.ts | 19 + .../client-search/model/searchResponses.ts | 5 + .../client-search/model/searchStrategy.ts | 1 + .../client-search/model/searchType.ts | 4 + .../client-search/src/searchClient.ts | 138 +++---- .../recommend/model/baseSearchParams.ts | 4 + .../packages/recommend/model/index.ts | 1 - .../recommend/model/searchParamsObject.ts | 5 +- .../lib/Api/SearchClient.php | 156 ++++---- .../lib/Model/Recommend/BaseSearchParams.php | 31 ++ .../Model/Recommend/SearchParamsObject.php | 68 ++-- .../lib/Model/Search/BaseSearchParams.php | 31 ++ .../lib/Model/Search/ConsequenceParams.php | 2 +- .../lib/Model/Search/SearchMethodParams.php | 247 +++++++++++++ .../lib/Model/Search/SearchParams.php | 68 ++-- .../lib/Model/Search/SearchParamsObject.php | 68 ++-- .../lib/Model/Search/SearchQueries.php | 340 ++++++++++++++++++ .../lib/Model/Search/SearchResponses.php | 209 +++++++++++ .../lib/Model/Search/SearchStrategy.php | 29 ++ .../lib/Model/Search/SearchType.php | 31 ++ specs/bundled/algoliasearch-lite.yml | 74 +--- specs/bundled/recommend.yml | 19 +- specs/bundled/search.yml | 50 ++- .../algolia/methods/requests/search.test.java | 298 ++++++++------- .../javascript/src/client/search.test.ts | 6 +- .../requests/algoliasearch-lite.test.ts | 140 ++++---- .../src/methods/requests/search.test.ts | 169 +++++---- .../php/src/methods/requests/SearchTest.php | 178 +++++---- 52 files changed, 2380 insertions(+), 946 deletions(-) create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchMethodParams.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponses.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchStrategy.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchMethodParams.ts create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchResponses.ts create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchStrategy.ts create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/searchMethodParams.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/searchResponses.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/searchStrategy.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts create mode 100644 clients/algoliasearch-client-php/lib/Model/Search/SearchMethodParams.php create mode 100644 clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php create mode 100644 clients/algoliasearch-client-php/lib/Model/Search/SearchResponses.php create mode 100644 clients/algoliasearch-client-php/lib/Model/Search/SearchStrategy.php create mode 100644 clients/algoliasearch-client-php/lib/Model/Search/SearchType.php diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java index d5d5e1affe..e9472a45fb 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/api/SearchClient.java @@ -3717,79 +3717,6 @@ public CompletableFuture multipleBatchAsync( return this.multipleBatchAsync(batchParams, null); } - /** - * Perform a search operation targeting one or many indices. - * - * @param multipleQueriesParams (required) - * @param requestOptions The requestOptions to send along with the query, they will be merged with - * the transporter requestOptions. - * @return MultipleQueriesResponse - * @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot - * deserialize the response body - */ - public MultipleQueriesResponse multipleQueries( - MultipleQueriesParams multipleQueriesParams, - RequestOptions requestOptions - ) throws AlgoliaRuntimeException { - return LaunderThrowable.await( - multipleQueriesAsync(multipleQueriesParams, requestOptions) - ); - } - - public MultipleQueriesResponse multipleQueries( - MultipleQueriesParams multipleQueriesParams - ) throws AlgoliaRuntimeException { - return this.multipleQueries(multipleQueriesParams, null); - } - - /** - * (asynchronously) Perform a search operation targeting one or many indices. - * - * @param multipleQueriesParams (required) - * @param requestOptions The requestOptions to send along with the query, they will be merged with - * the transporter requestOptions. - * @return The awaitable future - * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request - * body object - */ - public CompletableFuture multipleQueriesAsync( - MultipleQueriesParams multipleQueriesParams, - RequestOptions requestOptions - ) throws AlgoliaRuntimeException { - if (multipleQueriesParams == null) { - throw new AlgoliaRuntimeException( - "Missing the required parameter 'multipleQueriesParams' when calling" + - " multipleQueries(Async)" - ); - } - - Object bodyObj = multipleQueriesParams; - - // create path and map variables - String requestPath = "/1/indexes/*/queries"; - - Map queryParameters = new HashMap(); - Map headers = new HashMap(); - - Call call = - this.buildCall( - requestPath, - "POST", - queryParameters, - bodyObj, - headers, - requestOptions - ); - Type returnType = new TypeToken() {}.getType(); - return this.executeAsync(call, returnType); - } - - public CompletableFuture multipleQueriesAsync( - MultipleQueriesParams multipleQueriesParams - ) throws AlgoliaRuntimeException { - return this.multipleQueriesAsync(multipleQueriesParams, null); - } - /** * Performs a copy or a move operation on a index. * @@ -5125,67 +5052,53 @@ public CompletableFuture saveSynonymsAsync( } /** - * Perform a search operation targeting one specific index. + * Perform a search operation targeting one or many indices. * - * @param indexName The index in which to perform the request. (required) - * @param searchParams (required) + * @param searchMethodParams (required) * @param requestOptions The requestOptions to send along with the query, they will be merged with * the transporter requestOptions. - * @return SearchResponse + * @return SearchResponses * @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot * deserialize the response body */ - public SearchResponse search( - String indexName, - SearchParams searchParams, + public SearchResponses search( + SearchMethodParams searchMethodParams, RequestOptions requestOptions ) throws AlgoliaRuntimeException { return LaunderThrowable.await( - searchAsync(indexName, searchParams, requestOptions) + searchAsync(searchMethodParams, requestOptions) ); } - public SearchResponse search(String indexName, SearchParams searchParams) + public SearchResponses search(SearchMethodParams searchMethodParams) throws AlgoliaRuntimeException { - return this.search(indexName, searchParams, null); + return this.search(searchMethodParams, null); } /** - * (asynchronously) Perform a search operation targeting one specific index. + * (asynchronously) Perform a search operation targeting one or many indices. * - * @param indexName The index in which to perform the request. (required) - * @param searchParams (required) + * @param searchMethodParams (required) * @param requestOptions The requestOptions to send along with the query, they will be merged with * the transporter requestOptions. * @return The awaitable future * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request * body object */ - public CompletableFuture searchAsync( - String indexName, - SearchParams searchParams, + public CompletableFuture searchAsync( + SearchMethodParams searchMethodParams, RequestOptions requestOptions ) throws AlgoliaRuntimeException { - if (indexName == null) { - throw new AlgoliaRuntimeException( - "Missing the required parameter 'indexName' when calling search(Async)" - ); - } - - if (searchParams == null) { + if (searchMethodParams == null) { throw new AlgoliaRuntimeException( - "Missing the required parameter 'searchParams' when calling search(Async)" + "Missing the required parameter 'searchMethodParams' when calling search(Async)" ); } - Object bodyObj = searchParams; + Object bodyObj = searchMethodParams; // create path and map variables - String requestPath = - "/1/indexes/{indexName}/query".replaceAll( - "\\{indexName\\}", - this.escapeString(indexName.toString()) - ); + String requestPath = "/1/indexes/*/queries"; Map queryParameters = new HashMap(); Map headers = new HashMap(); @@ -5199,15 +5112,14 @@ public CompletableFuture searchAsync( headers, requestOptions ); - Type returnType = new TypeToken() {}.getType(); + Type returnType = new TypeToken() {}.getType(); return this.executeAsync(call, returnType); } - public CompletableFuture searchAsync( - String indexName, - SearchParams searchParams + public CompletableFuture searchAsync( + SearchMethodParams searchMethodParams ) throws AlgoliaRuntimeException { - return this.searchAsync(indexName, searchParams, null); + return this.searchAsync(searchMethodParams, null); } /** @@ -5553,6 +5465,94 @@ public CompletableFuture searchRulesAsync( return this.searchRulesAsync(indexName, searchRulesParams, null); } + /** + * Perform a search operation targeting one specific index. + * + * @param indexName The index in which to perform the request. (required) + * @param searchParams (required) + * @param requestOptions The requestOptions to send along with the query, they will be merged with + * the transporter requestOptions. + * @return SearchResponse + * @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot + * deserialize the response body + */ + public SearchResponse searchSingleIndex( + String indexName, + SearchParams searchParams, + RequestOptions requestOptions + ) throws AlgoliaRuntimeException { + return LaunderThrowable.await( + searchSingleIndexAsync(indexName, searchParams, requestOptions) + ); + } + + public SearchResponse searchSingleIndex( + String indexName, + SearchParams searchParams + ) throws AlgoliaRuntimeException { + return this.searchSingleIndex(indexName, searchParams, null); + } + + /** + * (asynchronously) Perform a search operation targeting one specific index. + * + * @param indexName The index in which to perform the request. (required) + * @param searchParams (required) + * @param requestOptions The requestOptions to send along with the query, they will be merged with + * the transporter requestOptions. + * @return The awaitable future + * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request + * body object + */ + public CompletableFuture searchSingleIndexAsync( + String indexName, + SearchParams searchParams, + RequestOptions requestOptions + ) throws AlgoliaRuntimeException { + if (indexName == null) { + throw new AlgoliaRuntimeException( + "Missing the required parameter 'indexName' when calling searchSingleIndex(Async)" + ); + } + + if (searchParams == null) { + throw new AlgoliaRuntimeException( + "Missing the required parameter 'searchParams' when calling searchSingleIndex(Async)" + ); + } + + Object bodyObj = searchParams; + + // create path and map variables + String requestPath = + "/1/indexes/{indexName}/query".replaceAll( + "\\{indexName\\}", + this.escapeString(indexName.toString()) + ); + + Map queryParameters = new HashMap(); + Map headers = new HashMap(); + + Call call = + this.buildCall( + requestPath, + "POST", + queryParameters, + bodyObj, + headers, + requestOptions + ); + Type returnType = new TypeToken() {}.getType(); + return this.executeAsync(call, returnType); + } + + public CompletableFuture searchSingleIndexAsync( + String indexName, + SearchParams searchParams + ) throws AlgoliaRuntimeException { + return this.searchSingleIndexAsync(indexName, searchParams, null); + } + /** * Search or browse all synonyms, optionally filtering them by type. * diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchParams.java index c22ec10dae..98f8443f95 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/BaseSearchParams.java @@ -9,6 +9,9 @@ /** BaseSearchParams */ public class BaseSearchParams { + @SerializedName("query") + private String query = ""; + @SerializedName("similarQuery") private String similarQuery = ""; @@ -108,6 +111,21 @@ public class BaseSearchParams { @SerializedName("reRankingApplyFilter") private ReRankingApplyFilter reRankingApplyFilter; + public BaseSearchParams setQuery(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nullable + public String getQuery() { + return query; + } + public BaseSearchParams setSimilarQuery(String similarQuery) { this.similarQuery = similarQuery; return this; @@ -679,6 +697,7 @@ public boolean equals(Object o) { } BaseSearchParams baseSearchParams = (BaseSearchParams) o; return ( + Objects.equals(this.query, baseSearchParams.query) && Objects.equals(this.similarQuery, baseSearchParams.similarQuery) && Objects.equals(this.filters, baseSearchParams.filters) && Objects.equals(this.facetFilters, baseSearchParams.facetFilters) && @@ -751,6 +770,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( + query, similarQuery, filters, facetFilters, @@ -791,6 +811,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BaseSearchParams {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb .append(" similarQuery: ") .append(toIndentedString(similarQuery)) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/SearchParamsObject.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/SearchParamsObject.java index 6177c8c5c9..6822bdca3a 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/SearchParamsObject.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/SearchParamsObject.java @@ -9,6 +9,9 @@ /** SearchParamsObject */ public class SearchParamsObject { + @SerializedName("query") + private String query = ""; + @SerializedName("similarQuery") private String similarQuery = ""; @@ -108,9 +111,6 @@ public class SearchParamsObject { @SerializedName("reRankingApplyFilter") private ReRankingApplyFilter reRankingApplyFilter; - @SerializedName("query") - private String query = ""; - @SerializedName("searchableAttributes") private List searchableAttributes = null; @@ -245,6 +245,21 @@ public class SearchParamsObject { @SerializedName("renderingContent") private Object renderingContent = new Object(); + public SearchParamsObject setQuery(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nullable + public String getQuery() { + return query; + } + public SearchParamsObject setSimilarQuery(String similarQuery) { this.similarQuery = similarQuery; return this; @@ -810,21 +825,6 @@ public ReRankingApplyFilter getReRankingApplyFilter() { return reRankingApplyFilter; } - public SearchParamsObject setQuery(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - public SearchParamsObject setSearchableAttributes( List searchableAttributes ) { @@ -1702,6 +1702,7 @@ public boolean equals(Object o) { } SearchParamsObject searchParamsObject = (SearchParamsObject) o; return ( + Objects.equals(this.query, searchParamsObject.query) && Objects.equals(this.similarQuery, searchParamsObject.similarQuery) && Objects.equals(this.filters, searchParamsObject.filters) && Objects.equals(this.facetFilters, searchParamsObject.facetFilters) && @@ -1777,7 +1778,6 @@ public boolean equals(Object o) { this.reRankingApplyFilter, searchParamsObject.reRankingApplyFilter ) && - Objects.equals(this.query, searchParamsObject.query) && Objects.equals( this.searchableAttributes, searchParamsObject.searchableAttributes @@ -1912,6 +1912,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( + query, similarQuery, filters, facetFilters, @@ -1945,7 +1946,6 @@ public int hashCode() { enableABTest, enableReRanking, reRankingApplyFilter, - query, searchableAttributes, attributesForFaceting, unretrievableAttributes, @@ -1997,6 +1997,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SearchParamsObject {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb .append(" similarQuery: ") .append(toIndentedString(similarQuery)) @@ -2114,7 +2115,6 @@ public String toString() { .append(" reRankingApplyFilter: ") .append(toIndentedString(reRankingApplyFilter)) .append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb .append(" searchableAttributes: ") .append(toIndentedString(searchableAttributes)) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchParams.java index ba1299c2f9..65fc3200c7 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/BaseSearchParams.java @@ -9,6 +9,9 @@ /** BaseSearchParams */ public class BaseSearchParams { + @SerializedName("query") + private String query = ""; + @SerializedName("similarQuery") private String similarQuery = ""; @@ -108,6 +111,21 @@ public class BaseSearchParams { @SerializedName("reRankingApplyFilter") private ReRankingApplyFilter reRankingApplyFilter; + public BaseSearchParams setQuery(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nullable + public String getQuery() { + return query; + } + public BaseSearchParams setSimilarQuery(String similarQuery) { this.similarQuery = similarQuery; return this; @@ -679,6 +697,7 @@ public boolean equals(Object o) { } BaseSearchParams baseSearchParams = (BaseSearchParams) o; return ( + Objects.equals(this.query, baseSearchParams.query) && Objects.equals(this.similarQuery, baseSearchParams.similarQuery) && Objects.equals(this.filters, baseSearchParams.filters) && Objects.equals(this.facetFilters, baseSearchParams.facetFilters) && @@ -751,6 +770,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( + query, similarQuery, filters, facetFilters, @@ -791,6 +811,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BaseSearchParams {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb .append(" similarQuery: ") .append(toIndentedString(similarQuery)) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ConsequenceParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ConsequenceParams.java index 0c997d269c..7764352a50 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ConsequenceParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/ConsequenceParams.java @@ -10,7 +10,7 @@ public class ConsequenceParams { @SerializedName("query") - private String query; + private String query = ""; @SerializedName("automaticFacetFilters") private List automaticFacetFilters = null; @@ -257,7 +257,7 @@ public ConsequenceParams setQuery(String query) { } /** - * Query string. + * The text to search in the index. * * @return query */ diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchMethodParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchMethodParams.java new file mode 100644 index 0000000000..42f6b7b40f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchMethodParams.java @@ -0,0 +1,91 @@ +package com.algolia.model.search; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** SearchMethodParams */ +public class SearchMethodParams { + + @SerializedName("requests") + private List requests = new ArrayList<>(); + + @SerializedName("strategy") + private SearchStrategy strategy; + + public SearchMethodParams setRequests(List requests) { + this.requests = requests; + return this; + } + + public SearchMethodParams addRequests(SearchQueries requestsItem) { + this.requests.add(requestsItem); + return this; + } + + /** + * Get requests + * + * @return requests + */ + @javax.annotation.Nonnull + public List getRequests() { + return requests; + } + + public SearchMethodParams setStrategy(SearchStrategy strategy) { + this.strategy = strategy; + return this; + } + + /** + * Get strategy + * + * @return strategy + */ + @javax.annotation.Nullable + public SearchStrategy getStrategy() { + return strategy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchMethodParams searchMethodParams = (SearchMethodParams) o; + return ( + Objects.equals(this.requests, searchMethodParams.requests) && + Objects.equals(this.strategy, searchMethodParams.strategy) + ); + } + + @Override + public int hashCode() { + return Objects.hash(requests, strategy); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchMethodParams {\n"); + sb.append(" requests: ").append(toIndentedString(requests)).append("\n"); + sb.append(" strategy: ").append(toIndentedString(strategy)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchParamsObject.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchParamsObject.java index b9ec693e2b..5a93e416d4 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchParamsObject.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchParamsObject.java @@ -9,6 +9,9 @@ /** SearchParamsObject */ public class SearchParamsObject { + @SerializedName("query") + private String query = ""; + @SerializedName("similarQuery") private String similarQuery = ""; @@ -108,9 +111,6 @@ public class SearchParamsObject { @SerializedName("reRankingApplyFilter") private ReRankingApplyFilter reRankingApplyFilter; - @SerializedName("query") - private String query = ""; - @SerializedName("searchableAttributes") private List searchableAttributes = null; @@ -245,6 +245,21 @@ public class SearchParamsObject { @SerializedName("renderingContent") private Object renderingContent = new Object(); + public SearchParamsObject setQuery(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nullable + public String getQuery() { + return query; + } + public SearchParamsObject setSimilarQuery(String similarQuery) { this.similarQuery = similarQuery; return this; @@ -810,21 +825,6 @@ public ReRankingApplyFilter getReRankingApplyFilter() { return reRankingApplyFilter; } - public SearchParamsObject setQuery(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - public SearchParamsObject setSearchableAttributes( List searchableAttributes ) { @@ -1702,6 +1702,7 @@ public boolean equals(Object o) { } SearchParamsObject searchParamsObject = (SearchParamsObject) o; return ( + Objects.equals(this.query, searchParamsObject.query) && Objects.equals(this.similarQuery, searchParamsObject.similarQuery) && Objects.equals(this.filters, searchParamsObject.filters) && Objects.equals(this.facetFilters, searchParamsObject.facetFilters) && @@ -1777,7 +1778,6 @@ public boolean equals(Object o) { this.reRankingApplyFilter, searchParamsObject.reRankingApplyFilter ) && - Objects.equals(this.query, searchParamsObject.query) && Objects.equals( this.searchableAttributes, searchParamsObject.searchableAttributes @@ -1912,6 +1912,7 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( + query, similarQuery, filters, facetFilters, @@ -1945,7 +1946,6 @@ public int hashCode() { enableABTest, enableReRanking, reRankingApplyFilter, - query, searchableAttributes, attributesForFaceting, unretrievableAttributes, @@ -1997,6 +1997,7 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SearchParamsObject {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb .append(" similarQuery: ") .append(toIndentedString(similarQuery)) @@ -2114,7 +2115,6 @@ public String toString() { .append(" reRankingApplyFilter: ") .append(toIndentedString(reRankingApplyFilter)) .append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); sb .append(" searchableAttributes: ") .append(toIndentedString(searchableAttributes)) diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java new file mode 100644 index 0000000000..12e9f3117b --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchQueries.java @@ -0,0 +1,147 @@ +package com.algolia.model.search; + +import com.google.gson.annotations.SerializedName; +import java.util.Objects; + +/** SearchQueries */ +public class SearchQueries { + + @SerializedName("indexName") + private String indexName; + + @SerializedName("query") + private String query = ""; + + @SerializedName("type") + private SearchType type = SearchType.DEFAULT; + + @SerializedName("facet") + private String facet; + + @SerializedName("params") + private SearchParams params; + + public SearchQueries setIndexName(String indexName) { + this.indexName = indexName; + return this; + } + + /** + * The Algolia index name. + * + * @return indexName + */ + @javax.annotation.Nonnull + public String getIndexName() { + return indexName; + } + + public SearchQueries setQuery(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nullable + public String getQuery() { + return query; + } + + public SearchQueries setType(SearchType type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @javax.annotation.Nullable + public SearchType getType() { + return type; + } + + public SearchQueries setFacet(String facet) { + this.facet = facet; + return this; + } + + /** + * The `facet` name. + * + * @return facet + */ + @javax.annotation.Nullable + public String getFacet() { + return facet; + } + + public SearchQueries setParams(SearchParams params) { + this.params = params; + return this; + } + + /** + * Get params + * + * @return params + */ + @javax.annotation.Nullable + public SearchParams getParams() { + return params; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchQueries searchQueries = (SearchQueries) o; + return ( + Objects.equals(this.indexName, searchQueries.indexName) && + Objects.equals(this.query, searchQueries.query) && + Objects.equals(this.type, searchQueries.type) && + Objects.equals(this.facet, searchQueries.facet) && + Objects.equals(this.params, searchQueries.params) + ); + } + + @Override + public int hashCode() { + return Objects.hash(indexName, query, type, facet, params); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchQueries {\n"); + sb + .append(" indexName: ") + .append(toIndentedString(indexName)) + .append("\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" facet: ").append(toIndentedString(facet)).append("\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponses.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponses.java new file mode 100644 index 0000000000..c6ce5d716c --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchResponses.java @@ -0,0 +1,72 @@ +package com.algolia.model.search; + +import com.google.gson.annotations.SerializedName; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** SearchResponses */ +public class SearchResponses { + + @SerializedName("results") + private List results = null; + + public SearchResponses setResults(List results) { + this.results = results; + return this; + } + + public SearchResponses addResults(SearchResponse resultsItem) { + if (this.results == null) { + this.results = new ArrayList<>(); + } + this.results.add(resultsItem); + return this; + } + + /** + * Get results + * + * @return results + */ + @javax.annotation.Nullable + public List getResults() { + return results; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchResponses searchResponses = (SearchResponses) o; + return Objects.equals(this.results, searchResponses.results); + } + + @Override + public int hashCode() { + return Objects.hash(results); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchResponses {\n"); + sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchStrategy.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchStrategy.java new file mode 100644 index 0000000000..ad2f799040 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchStrategy.java @@ -0,0 +1,56 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** Gets or Sets searchStrategy */ +@JsonAdapter(SearchStrategy.Adapter.class) +public enum SearchStrategy { + NONE("none"), + + STOP_IF_ENOUGH_MATCHES("stopIfEnoughMatches"); + + private final String value; + + SearchStrategy(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SearchStrategy fromValue(String value) { + for (SearchStrategy b : SearchStrategy.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final SearchStrategy enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SearchStrategy read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SearchStrategy.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java new file mode 100644 index 0000000000..3f41b53b88 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/search/SearchType.java @@ -0,0 +1,56 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** Perform a search query with `default`, will search for facet values if `facet` is given. */ +@JsonAdapter(SearchType.Adapter.class) +public enum SearchType { + DEFAULT("default"), + + FACET("facet"); + + private final String value; + + SearchType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SearchType fromValue(String value) { + for (SearchType b : SearchType.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final SearchType enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SearchType read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SearchType.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchParams.ts index ee0468114d..d43675f196 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/baseSearchParams.ts @@ -6,6 +6,10 @@ import type { ReRankingApplyFilter } from './reRankingApplyFilter'; import type { TagFilters } from './tagFilters'; export type BaseSearchParams = { + /** + * The text to search in the index. + */ + query?: string; /** * Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results. */ diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts index 942b52d54e..42bb992575 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/index.ts @@ -41,11 +41,6 @@ export * from './listIndicesResponse'; export * from './logType'; export * from './matchLevel'; export * from './matchedGeoLocation'; -export * from './multipleQueries'; -export * from './multipleQueriesParams'; -export * from './multipleQueriesResponse'; -export * from './multipleQueriesStrategy'; -export * from './multipleQueriesType'; export * from './numericFilters'; export * from './operationType'; export * from './optionalFilters'; @@ -56,18 +51,22 @@ export * from './queryType'; export * from './rankingInfo'; export * from './reRankingApplyFilter'; export * from './removeWordsIfNoResults'; -export * from './requiredSearchParams'; export * from './rule'; export * from './scopeType'; export * from './searchForFacetValuesRequest'; export * from './searchForFacetValuesResponse'; export * from './searchForFacetValuesResponseFacetHits'; export * from './searchHits'; +export * from './searchMethodParams'; export * from './searchParams'; export * from './searchParamsObject'; export * from './searchParamsString'; +export * from './searchQueries'; export * from './searchResponse'; +export * from './searchResponses'; +export * from './searchStrategy'; export * from './searchSynonymsResponse'; +export * from './searchType'; export * from './snippetResult'; export * from './source'; export * from './standardEntries'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchMethodParams.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchMethodParams.ts new file mode 100644 index 0000000000..908b1af7d2 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchMethodParams.ts @@ -0,0 +1,7 @@ +import type { SearchQueries } from './searchQueries'; +import type { SearchStrategy } from './searchStrategy'; + +export type SearchMethodParams = { + requests: SearchQueries[]; + strategy?: SearchStrategy; +}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchParamsObject.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchParamsObject.ts index ad8f80c073..626a977f7b 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchParamsObject.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchParamsObject.ts @@ -1,7 +1,4 @@ import type { BaseSearchParams } from './baseSearchParams'; import type { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams'; -import type { RequiredSearchParams } from './requiredSearchParams'; -export type SearchParamsObject = BaseSearchParams & - IndexSettingsAsSearchParams & - RequiredSearchParams; +export type SearchParamsObject = BaseSearchParams & IndexSettingsAsSearchParams; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts new file mode 100644 index 0000000000..ffcc3805f7 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchQueries.ts @@ -0,0 +1,19 @@ +import type { SearchParams } from './searchParams'; +import type { SearchType } from './searchType'; + +export type SearchQueries = { + /** + * The Algolia index name. + */ + indexName: string; + /** + * The text to search in the index. + */ + query?: string; + type?: SearchType; + /** + * The `facet` name. + */ + facet?: string; + params?: SearchParams; +}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchResponses.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchResponses.ts new file mode 100644 index 0000000000..42d915cba1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchResponses.ts @@ -0,0 +1,5 @@ +import type { SearchResponse } from './searchResponse'; + +export type SearchResponses = { + results?: SearchResponse[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchStrategy.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchStrategy.ts new file mode 100644 index 0000000000..41fd212b6a --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchStrategy.ts @@ -0,0 +1 @@ +export type SearchStrategy = 'none' | 'stopIfEnoughMatches'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts new file mode 100644 index 0000000000..a6fb7e84f3 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/searchType.ts @@ -0,0 +1,4 @@ +/** + * Perform a search query with `default`, will search for facet values if `facet` is given. + */ +export type SearchType = 'default' | 'facet'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/src/algoliasearchLiteClient.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/src/algoliasearchLiteClient.ts index 6fa7119432..e223757348 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/src/algoliasearchLiteClient.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch-lite/src/algoliasearchLiteClient.ts @@ -13,12 +13,10 @@ import type { QueryParameters, } from '@experimental-api-clients-automation/client-common'; -import type { MultipleQueriesParams } from '../model/multipleQueriesParams'; -import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; import type { SearchForFacetValuesRequest } from '../model/searchForFacetValuesRequest'; import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse'; -import type { SearchParams } from '../model/searchParams'; -import type { SearchResponse } from '../model/searchResponse'; +import type { SearchMethodParams } from '../model/searchMethodParams'; +import type { SearchResponses } from '../model/searchResponses'; export * from '../model'; export const apiClientVersion = '0.2.0'; @@ -86,49 +84,6 @@ export function createAlgoliasearchLiteClient(options: CreateClientOptions) { return { addAlgoliaAgent, - /** - * Perform a search operation targeting one or many indices. - * - * @summary Search multiple indices. - * @param multipleQueriesParams - The multipleQueriesParams object. - * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. - */ - multipleQueries( - multipleQueriesParams: MultipleQueriesParams, - requestOptions?: RequestOptions - ): Promise { - if (!multipleQueriesParams) { - throw new Error( - 'Parameter `multipleQueriesParams` is required when calling `multipleQueries`.' - ); - } - - if (!multipleQueriesParams.requests) { - throw new Error( - 'Parameter `multipleQueriesParams.requests` is required when calling `multipleQueries`.' - ); - } - - const requestPath = '/1/indexes/*/queries'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - - const request: Request = { - method: 'POST', - path: requestPath, - data: multipleQueriesParams, - }; - - return transporter.request( - request, - { - queryParameters, - headers, - }, - requestOptions - ); - }, - /** * This method allow you to send requests to the Algolia REST API. * @@ -168,41 +123,36 @@ export function createAlgoliasearchLiteClient(options: CreateClientOptions) { }, /** - * Perform a search operation targeting one specific index. + * Perform a search operation targeting one or many indices. * - * @summary Search in an index. - * @param search - The search object. - * @param search.indexName - The index in which to perform the request. - * @param search.searchParams - The searchParams object. + * @summary Search multiple indices. + * @param searchMethodParams - The searchMethodParams object. * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. */ search( - { indexName, searchParams }: SearchProps, + searchMethodParams: SearchMethodParams, requestOptions?: RequestOptions - ): Promise { - if (!indexName) { + ): Promise { + if (!searchMethodParams) { throw new Error( - 'Parameter `indexName` is required when calling `search`.' + 'Parameter `searchMethodParams` is required when calling `search`.' ); } - if (!searchParams) { + if (!searchMethodParams.requests) { throw new Error( - 'Parameter `searchParams` is required when calling `search`.' + 'Parameter `searchMethodParams.requests` is required when calling `search`.' ); } - const requestPath = '/1/indexes/{indexName}/query'.replace( - '{indexName}', - encodeURIComponent(indexName) - ); + const requestPath = '/1/indexes/*/queries'; const headers: Headers = {}; const queryParameters: QueryParameters = {}; const request: Request = { method: 'POST', path: requestPath, - data: searchParams, + data: searchMethodParams, }; return transporter.request( @@ -288,14 +238,6 @@ export type PostProps = { body?: Record; }; -export type SearchProps = { - /** - * The index in which to perform the request. - */ - indexName: string; - searchParams: SearchParams; -}; - export type SearchForFacetValuesProps = { /** * The index in which to perform the request. diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts index ee0468114d..d43675f196 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts @@ -6,6 +6,10 @@ import type { ReRankingApplyFilter } from './reRankingApplyFilter'; import type { TagFilters } from './tagFilters'; export type BaseSearchParams = { + /** + * The text to search in the index. + */ + query?: string; /** * Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts index b24160123e..21a54915f8 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/index.ts @@ -69,11 +69,6 @@ export * from './matchedGeoLocation'; export * from './multipleBatchOperation'; export * from './multipleBatchResponse'; export * from './multipleGetObjectsParams'; -export * from './multipleQueries'; -export * from './multipleQueriesParams'; -export * from './multipleQueriesResponse'; -export * from './multipleQueriesStrategy'; -export * from './multipleQueriesType'; export * from './numericFilters'; export * from './operationIndexParams'; export * from './operationType'; @@ -87,7 +82,6 @@ export * from './reRankingApplyFilter'; export * from './removeUserIdResponse'; export * from './removeWordsIfNoResults'; export * from './replaceSourceResponse'; -export * from './requiredSearchParams'; export * from './rule'; export * from './saveObjectResponse'; export * from './saveSynonymResponse'; @@ -97,13 +91,18 @@ export * from './searchForFacetValuesRequest'; export * from './searchForFacetValuesResponse'; export * from './searchForFacetValuesResponseFacetHits'; export * from './searchHits'; +export * from './searchMethodParams'; export * from './searchParams'; export * from './searchParamsObject'; export * from './searchParamsString'; +export * from './searchQueries'; export * from './searchResponse'; +export * from './searchResponses'; export * from './searchRulesParams'; export * from './searchRulesResponse'; +export * from './searchStrategy'; export * from './searchSynonymsResponse'; +export * from './searchType'; export * from './searchUserIdsParams'; export * from './searchUserIdsResponse'; export * from './searchUserIdsResponseHighlightResult'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchMethodParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchMethodParams.ts new file mode 100644 index 0000000000..908b1af7d2 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/searchMethodParams.ts @@ -0,0 +1,7 @@ +import type { SearchQueries } from './searchQueries'; +import type { SearchStrategy } from './searchStrategy'; + +export type SearchMethodParams = { + requests: SearchQueries[]; + strategy?: SearchStrategy; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchParamsObject.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchParamsObject.ts index ad8f80c073..626a977f7b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/searchParamsObject.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/searchParamsObject.ts @@ -1,7 +1,4 @@ import type { BaseSearchParams } from './baseSearchParams'; import type { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams'; -import type { RequiredSearchParams } from './requiredSearchParams'; -export type SearchParamsObject = BaseSearchParams & - IndexSettingsAsSearchParams & - RequiredSearchParams; +export type SearchParamsObject = BaseSearchParams & IndexSettingsAsSearchParams; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts new file mode 100644 index 0000000000..ffcc3805f7 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/searchQueries.ts @@ -0,0 +1,19 @@ +import type { SearchParams } from './searchParams'; +import type { SearchType } from './searchType'; + +export type SearchQueries = { + /** + * The Algolia index name. + */ + indexName: string; + /** + * The text to search in the index. + */ + query?: string; + type?: SearchType; + /** + * The `facet` name. + */ + facet?: string; + params?: SearchParams; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchResponses.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchResponses.ts new file mode 100644 index 0000000000..42d915cba1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/searchResponses.ts @@ -0,0 +1,5 @@ +import type { SearchResponse } from './searchResponse'; + +export type SearchResponses = { + results?: SearchResponse[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchStrategy.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchStrategy.ts new file mode 100644 index 0000000000..41fd212b6a --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/searchStrategy.ts @@ -0,0 +1 @@ +export type SearchStrategy = 'none' | 'stopIfEnoughMatches'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts new file mode 100644 index 0000000000..a6fb7e84f3 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/searchType.ts @@ -0,0 +1,4 @@ +/** + * Perform a search query with `default`, will search for facet values if `facet` is given. + */ +export type SearchType = 'default' | 'facet'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts index f1cc635401..a660102303 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts @@ -45,8 +45,6 @@ import type { ListIndicesResponse } from '../model/listIndicesResponse'; import type { ListUserIdsResponse } from '../model/listUserIdsResponse'; import type { LogType } from '../model/logType'; import type { MultipleBatchResponse } from '../model/multipleBatchResponse'; -import type { MultipleQueriesParams } from '../model/multipleQueriesParams'; -import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; import type { OperationIndexParams } from '../model/operationIndexParams'; import type { RemoveUserIdResponse } from '../model/removeUserIdResponse'; import type { ReplaceSourceResponse } from '../model/replaceSourceResponse'; @@ -56,8 +54,10 @@ import type { SaveSynonymResponse } from '../model/saveSynonymResponse'; import type { SearchDictionaryEntriesParams } from '../model/searchDictionaryEntriesParams'; import type { SearchForFacetValuesRequest } from '../model/searchForFacetValuesRequest'; import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse'; +import type { SearchMethodParams } from '../model/searchMethodParams'; import type { SearchParams } from '../model/searchParams'; import type { SearchResponse } from '../model/searchResponse'; +import type { SearchResponses } from '../model/searchResponses'; import type { SearchRulesParams } from '../model/searchRulesParams'; import type { SearchRulesResponse } from '../model/searchRulesResponse'; import type { SearchSynonymsResponse } from '../model/searchSynonymsResponse'; @@ -1822,49 +1822,6 @@ export function createSearchClient(options: CreateClientOptions) { ); }, - /** - * Perform a search operation targeting one or many indices. - * - * @summary Search multiple indices. - * @param multipleQueriesParams - The multipleQueriesParams object. - * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. - */ - multipleQueries( - multipleQueriesParams: MultipleQueriesParams, - requestOptions?: RequestOptions - ): Promise { - if (!multipleQueriesParams) { - throw new Error( - 'Parameter `multipleQueriesParams` is required when calling `multipleQueries`.' - ); - } - - if (!multipleQueriesParams.requests) { - throw new Error( - 'Parameter `multipleQueriesParams.requests` is required when calling `multipleQueries`.' - ); - } - - const requestPath = '/1/indexes/*/queries'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - - const request: Request = { - method: 'POST', - path: requestPath, - data: multipleQueriesParams, - }; - - return transporter.request( - request, - { - queryParameters, - headers, - }, - requestOptions - ); - }, - /** * Performs a copy or a move operation on a index. * @@ -2430,41 +2387,36 @@ export function createSearchClient(options: CreateClientOptions) { }, /** - * Perform a search operation targeting one specific index. + * Perform a search operation targeting one or many indices. * - * @summary Search in an index. - * @param search - The search object. - * @param search.indexName - The index in which to perform the request. - * @param search.searchParams - The searchParams object. + * @summary Search multiple indices. + * @param searchMethodParams - The searchMethodParams object. * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. */ search( - { indexName, searchParams }: SearchProps, + searchMethodParams: SearchMethodParams, requestOptions?: RequestOptions - ): Promise { - if (!indexName) { + ): Promise { + if (!searchMethodParams) { throw new Error( - 'Parameter `indexName` is required when calling `search`.' + 'Parameter `searchMethodParams` is required when calling `search`.' ); } - if (!searchParams) { + if (!searchMethodParams.requests) { throw new Error( - 'Parameter `searchParams` is required when calling `search`.' + 'Parameter `searchMethodParams.requests` is required when calling `search`.' ); } - const requestPath = '/1/indexes/{indexName}/query'.replace( - '{indexName}', - encodeURIComponent(indexName) - ); + const requestPath = '/1/indexes/*/queries'; const headers: Headers = {}; const queryParameters: QueryParameters = {}; const request: Request = { method: 'POST', path: requestPath, - data: searchParams, + data: searchMethodParams, }; return transporter.request( @@ -2634,6 +2586,54 @@ export function createSearchClient(options: CreateClientOptions) { ); }, + /** + * Perform a search operation targeting one specific index. + * + * @summary Search in a single index. + * @param searchSingleIndex - The searchSingleIndex object. + * @param searchSingleIndex.indexName - The index in which to perform the request. + * @param searchSingleIndex.searchParams - The searchParams object. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + searchSingleIndex( + { indexName, searchParams }: SearchSingleIndexProps, + requestOptions?: RequestOptions + ): Promise { + if (!indexName) { + throw new Error( + 'Parameter `indexName` is required when calling `searchSingleIndex`.' + ); + } + + if (!searchParams) { + throw new Error( + 'Parameter `searchParams` is required when calling `searchSingleIndex`.' + ); + } + + const requestPath = '/1/indexes/{indexName}/query'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + + const request: Request = { + method: 'POST', + path: requestPath, + data: searchParams, + }; + + return transporter.request( + request, + { + queryParameters, + headers, + }, + requestOptions + ); + }, + /** * Search or browse all synonyms, optionally filtering them by type. * @@ -3335,14 +3335,6 @@ export type SaveSynonymsProps = { replaceExistingSynonyms?: boolean; }; -export type SearchProps = { - /** - * The index in which to perform the request. - */ - indexName: string; - searchParams: SearchParams; -}; - export type SearchDictionaryEntriesProps = { /** * The dictionary to search in. @@ -3371,6 +3363,14 @@ export type SearchRulesProps = { searchRulesParams: SearchRulesParams; }; +export type SearchSingleIndexProps = { + /** + * The index in which to perform the request. + */ + indexName: string; + searchParams: SearchParams; +}; + export type SearchSynonymsProps = { /** * The index in which to perform the request. diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts index ee0468114d..d43675f196 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts @@ -6,6 +6,10 @@ import type { ReRankingApplyFilter } from './reRankingApplyFilter'; import type { TagFilters } from './tagFilters'; export type BaseSearchParams = { + /** + * The text to search in the index. + */ + query?: string; /** * Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results. */ diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/index.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/index.ts index 7a0d0628f2..59d8508da6 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/model/index.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/index.ts @@ -30,7 +30,6 @@ export * from './recommendationRequest'; export * from './recommendationsRequest'; export * from './recommendationsResponse'; export * from './removeWordsIfNoResults'; -export * from './requiredSearchParams'; export * from './searchParamsObject'; export * from './snippetResult'; export * from './tagFilters'; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/searchParamsObject.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/searchParamsObject.ts index ad8f80c073..626a977f7b 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/model/searchParamsObject.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/searchParamsObject.ts @@ -1,7 +1,4 @@ import type { BaseSearchParams } from './baseSearchParams'; import type { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams'; -import type { RequiredSearchParams } from './requiredSearchParams'; -export type SearchParamsObject = BaseSearchParams & - IndexSettingsAsSearchParams & - RequiredSearchParams; +export type SearchParamsObject = BaseSearchParams & IndexSettingsAsSearchParams; diff --git a/clients/algoliasearch-client-php/lib/Api/SearchClient.php b/clients/algoliasearch-client-php/lib/Api/SearchClient.php index 5fe227de36..1934bd653d 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchClient.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchClient.php @@ -2041,53 +2041,6 @@ public function multipleBatch($batchParams, $requestOptions = []) ); } - /** - * Search multiple indices. - * - * @param array $multipleQueriesParams multipleQueriesParams (required) - * - $multipleQueriesParams['requests'] => (array) (required) - * - $multipleQueriesParams['strategy'] => (array) - * - * @see \Algolia\AlgoliaSearch\Model\Search\MultipleQueriesParams - * - * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions - * - * @return array|\Algolia\AlgoliaSearch\Model\Search\MultipleQueriesResponse - */ - public function multipleQueries( - $multipleQueriesParams, - $requestOptions = [] - ) { - // verify the required parameter 'multipleQueriesParams' is set - if ( - $multipleQueriesParams === null || - (is_array($multipleQueriesParams) && - count($multipleQueriesParams) === 0) - ) { - throw new \InvalidArgumentException( - 'Missing the required parameter $multipleQueriesParams when calling multipleQueries' - ); - } - - $resourcePath = '/1/indexes/*/queries'; - $queryParameters = []; - $headers = []; - $httpBody = []; - - if (isset($multipleQueriesParams)) { - $httpBody = $multipleQueriesParams; - } - - return $this->sendRequest( - 'POST', - $resourcePath, - $headers, - $queryParameters, - $httpBody, - $requestOptions - ); - } - /** * Copy/move index. * @@ -2792,54 +2745,37 @@ public function saveSynonyms( } /** - * Search in an index. + * Search multiple indices. * - * @param string $indexName The index in which to perform the request. (required) - * @param array $searchParams searchParams (required) + * @param array $searchMethodParams searchMethodParams (required) + * - $searchMethodParams['requests'] => (array) (required) + * - $searchMethodParams['strategy'] => (array) * - * @see \Algolia\AlgoliaSearch\Model\Search\SearchParams + * @see \Algolia\AlgoliaSearch\Model\Search\SearchMethodParams * * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * - * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchResponse + * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchResponses */ - public function search($indexName, $searchParams, $requestOptions = []) + public function search($searchMethodParams, $requestOptions = []) { - // verify the required parameter 'indexName' is set - if ( - $indexName === null || - (is_array($indexName) && count($indexName) === 0) - ) { - throw new \InvalidArgumentException( - 'Missing the required parameter $indexName when calling search' - ); - } - // verify the required parameter 'searchParams' is set + // verify the required parameter 'searchMethodParams' is set if ( - $searchParams === null || - (is_array($searchParams) && count($searchParams) === 0) + $searchMethodParams === null || + (is_array($searchMethodParams) && count($searchMethodParams) === 0) ) { throw new \InvalidArgumentException( - 'Missing the required parameter $searchParams when calling search' + 'Missing the required parameter $searchMethodParams when calling search' ); } - $resourcePath = '/1/indexes/{indexName}/query'; + $resourcePath = '/1/indexes/*/queries'; $queryParameters = []; $headers = []; $httpBody = []; - // path params - if ($indexName !== null) { - $resourcePath = str_replace( - '{indexName}', - ObjectSerializer::toPathValue($indexName), - $resourcePath - ); - } - - if (isset($searchParams)) { - $httpBody = $searchParams; + if (isset($searchMethodParams)) { + $httpBody = $searchMethodParams; } return $this->sendRequest( @@ -3070,6 +3006,70 @@ public function searchRules( ); } + /** + * Search in a single index. + * + * @param string $indexName The index in which to perform the request. (required) + * @param array $searchParams searchParams (required) + * + * @see \Algolia\AlgoliaSearch\Model\Search\SearchParams + * + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions + * + * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchResponse + */ + public function searchSingleIndex( + $indexName, + $searchParams, + $requestOptions = [] + ) { + // verify the required parameter 'indexName' is set + if ( + $indexName === null || + (is_array($indexName) && count($indexName) === 0) + ) { + throw new \InvalidArgumentException( + 'Missing the required parameter $indexName when calling searchSingleIndex' + ); + } + // verify the required parameter 'searchParams' is set + if ( + $searchParams === null || + (is_array($searchParams) && count($searchParams) === 0) + ) { + throw new \InvalidArgumentException( + 'Missing the required parameter $searchParams when calling searchSingleIndex' + ); + } + + $resourcePath = '/1/indexes/{indexName}/query'; + $queryParameters = []; + $headers = []; + $httpBody = []; + + // path params + if ($indexName !== null) { + $resourcePath = str_replace( + '{indexName}', + ObjectSerializer::toPathValue($indexName), + $resourcePath + ); + } + + if (isset($searchParams)) { + $httpBody = $searchParams; + } + + return $this->sendRequest( + 'POST', + $resourcePath, + $headers, + $queryParameters, + $httpBody, + $requestOptions + ); + } + /** * Search synonyms. * diff --git a/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchParams.php b/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchParams.php index e5d4629f21..4028c0d4e7 100644 --- a/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchParams.php +++ b/clients/algoliasearch-client-php/lib/Model/Recommend/BaseSearchParams.php @@ -19,6 +19,7 @@ class BaseSearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implem * @var string[] */ protected static $modelTypes = [ + 'query' => 'string', 'similarQuery' => 'string', 'filters' => 'string', 'facetFilters' => '\Algolia\AlgoliaSearch\Model\Recommend\FacetFilters', @@ -60,6 +61,7 @@ class BaseSearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implem * @var string[] */ protected static $modelFormats = [ + 'query' => null, 'similarQuery' => null, 'filters' => null, 'facetFilters' => null, @@ -121,6 +123,7 @@ public static function modelFormats() * @var string[] */ protected static $setters = [ + 'query' => 'setQuery', 'similarQuery' => 'setSimilarQuery', 'filters' => 'setFilters', 'facetFilters' => 'setFacetFilters', @@ -162,6 +165,7 @@ public static function modelFormats() * @var string[] */ protected static $getters = [ + 'query' => 'getQuery', 'similarQuery' => 'getSimilarQuery', 'filters' => 'getFilters', 'facetFilters' => 'getFacetFilters', @@ -231,6 +235,9 @@ public static function getters() */ public function __construct(array $data = null) { + if (isset($data['query'])) { + $this->container['query'] = $data['query']; + } if (isset($data['similarQuery'])) { $this->container['similarQuery'] = $data['similarQuery']; } @@ -385,6 +392,30 @@ public function valid() return count($this->listInvalidProperties()) === 0; } + /** + * Gets query + * + * @return string|null + */ + public function getQuery() + { + return $this->container['query'] ?? null; + } + + /** + * Sets query + * + * @param string|null $query the text to search in the index + * + * @return self + */ + public function setQuery($query) + { + $this->container['query'] = $query; + + return $this; + } + /** * Gets similarQuery * diff --git a/clients/algoliasearch-client-php/lib/Model/Recommend/SearchParamsObject.php b/clients/algoliasearch-client-php/lib/Model/Recommend/SearchParamsObject.php index 2ae2eb8146..b7585fdfcd 100644 --- a/clients/algoliasearch-client-php/lib/Model/Recommend/SearchParamsObject.php +++ b/clients/algoliasearch-client-php/lib/Model/Recommend/SearchParamsObject.php @@ -19,6 +19,7 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl * @var string[] */ protected static $modelTypes = [ + 'query' => 'string', 'similarQuery' => 'string', 'filters' => 'string', 'facetFilters' => '\Algolia\AlgoliaSearch\Model\Recommend\FacetFilters', @@ -52,7 +53,6 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl 'enableABTest' => 'bool', 'enableReRanking' => 'bool', 'reRankingApplyFilter' => '\Algolia\AlgoliaSearch\Model\Recommend\ReRankingApplyFilter', - 'query' => 'string', 'searchableAttributes' => 'string[]', 'attributesForFaceting' => 'string[]', 'unretrievableAttributes' => 'string[]', @@ -105,6 +105,7 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl * @var string[] */ protected static $modelFormats = [ + 'query' => null, 'similarQuery' => null, 'filters' => null, 'facetFilters' => null, @@ -138,7 +139,6 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl 'enableABTest' => null, 'enableReRanking' => null, 'reRankingApplyFilter' => null, - 'query' => null, 'searchableAttributes' => null, 'attributesForFaceting' => null, 'unretrievableAttributes' => null, @@ -211,6 +211,7 @@ public static function modelFormats() * @var string[] */ protected static $setters = [ + 'query' => 'setQuery', 'similarQuery' => 'setSimilarQuery', 'filters' => 'setFilters', 'facetFilters' => 'setFacetFilters', @@ -244,7 +245,6 @@ public static function modelFormats() 'enableABTest' => 'setEnableABTest', 'enableReRanking' => 'setEnableReRanking', 'reRankingApplyFilter' => 'setReRankingApplyFilter', - 'query' => 'setQuery', 'searchableAttributes' => 'setSearchableAttributes', 'attributesForFaceting' => 'setAttributesForFaceting', 'unretrievableAttributes' => 'setUnretrievableAttributes', @@ -297,6 +297,7 @@ public static function modelFormats() * @var string[] */ protected static $getters = [ + 'query' => 'getQuery', 'similarQuery' => 'getSimilarQuery', 'filters' => 'getFilters', 'facetFilters' => 'getFacetFilters', @@ -330,7 +331,6 @@ public static function modelFormats() 'enableABTest' => 'getEnableABTest', 'enableReRanking' => 'getEnableReRanking', 'reRankingApplyFilter' => 'getReRankingApplyFilter', - 'query' => 'getQuery', 'searchableAttributes' => 'getSearchableAttributes', 'attributesForFaceting' => 'getAttributesForFaceting', 'unretrievableAttributes' => 'getUnretrievableAttributes', @@ -411,6 +411,9 @@ public static function getters() */ public function __construct(array $data = null) { + if (isset($data['query'])) { + $this->container['query'] = $data['query']; + } if (isset($data['similarQuery'])) { $this->container['similarQuery'] = $data['similarQuery']; } @@ -516,9 +519,6 @@ public function __construct(array $data = null) $this->container['reRankingApplyFilter'] = $data['reRankingApplyFilter']; } - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } if (isset($data['searchableAttributes'])) { $this->container['searchableAttributes'] = $data['searchableAttributes']; @@ -709,12 +709,6 @@ public function listInvalidProperties() "invalid value for 'minimumAroundRadius', must be bigger than or equal to 1."; } - if ( - !isset($this->container['query']) || - $this->container['query'] === null - ) { - $invalidProperties[] = "'query' can't be null"; - } if ( isset($this->container['distinct']) && $this->container['distinct'] > 4 @@ -769,6 +763,30 @@ public function valid() return count($this->listInvalidProperties()) === 0; } + /** + * Gets query + * + * @return string|null + */ + public function getQuery() + { + return $this->container['query'] ?? null; + } + + /** + * Sets query + * + * @param string|null $query the text to search in the index + * + * @return self + */ + public function setQuery($query) + { + $this->container['query'] = $query; + + return $this; + } + /** * Gets similarQuery * @@ -1578,30 +1596,6 @@ public function setReRankingApplyFilter($reRankingApplyFilter) return $this; } - /** - * Gets query - * - * @return string - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - /** * Gets searchableAttributes * diff --git a/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchParams.php b/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchParams.php index 99ee8edfb1..a009599129 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchParams.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/BaseSearchParams.php @@ -19,6 +19,7 @@ class BaseSearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implem * @var string[] */ protected static $modelTypes = [ + 'query' => 'string', 'similarQuery' => 'string', 'filters' => 'string', 'facetFilters' => '\Algolia\AlgoliaSearch\Model\Search\FacetFilters', @@ -60,6 +61,7 @@ class BaseSearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implem * @var string[] */ protected static $modelFormats = [ + 'query' => null, 'similarQuery' => null, 'filters' => null, 'facetFilters' => null, @@ -121,6 +123,7 @@ public static function modelFormats() * @var string[] */ protected static $setters = [ + 'query' => 'setQuery', 'similarQuery' => 'setSimilarQuery', 'filters' => 'setFilters', 'facetFilters' => 'setFacetFilters', @@ -162,6 +165,7 @@ public static function modelFormats() * @var string[] */ protected static $getters = [ + 'query' => 'getQuery', 'similarQuery' => 'getSimilarQuery', 'filters' => 'getFilters', 'facetFilters' => 'getFacetFilters', @@ -231,6 +235,9 @@ public static function getters() */ public function __construct(array $data = null) { + if (isset($data['query'])) { + $this->container['query'] = $data['query']; + } if (isset($data['similarQuery'])) { $this->container['similarQuery'] = $data['similarQuery']; } @@ -385,6 +392,30 @@ public function valid() return count($this->listInvalidProperties()) === 0; } + /** + * Gets query + * + * @return string|null + */ + public function getQuery() + { + return $this->container['query'] ?? null; + } + + /** + * Sets query + * + * @param string|null $query the text to search in the index + * + * @return self + */ + public function setQuery($query) + { + $this->container['query'] = $query; + + return $this; + } + /** * Gets similarQuery * diff --git a/clients/algoliasearch-client-php/lib/Model/Search/ConsequenceParams.php b/clients/algoliasearch-client-php/lib/Model/Search/ConsequenceParams.php index d995d7a751..35dee629d3 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/ConsequenceParams.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/ConsequenceParams.php @@ -792,7 +792,7 @@ public function getQuery() /** * Sets query * - * @param string|null $query query string + * @param string|null $query the text to search in the index * * @return self */ diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchMethodParams.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchMethodParams.php new file mode 100644 index 0000000000..567e09b72a --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchMethodParams.php @@ -0,0 +1,247 @@ + '\Algolia\AlgoliaSearch\Model\Search\SearchQueries[]', + 'strategy' => '\Algolia\AlgoliaSearch\Model\Search\SearchStrategy', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $modelFormats = [ + 'requests' => null, + 'strategy' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function modelTypes() + { + return self::$modelTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function modelFormats() + { + return self::$modelFormats; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'requests' => 'setRequests', + 'strategy' => 'setStrategy', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'requests' => 'getRequests', + 'strategy' => 'getStrategy', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + */ + public function __construct(array $data = null) + { + if (isset($data['requests'])) { + $this->container['requests'] = $data['requests']; + } + if (isset($data['strategy'])) { + $this->container['strategy'] = $data['strategy']; + } + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ( + !isset($this->container['requests']) || + $this->container['requests'] === null + ) { + $invalidProperties[] = "'requests' can't be null"; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Gets requests + * + * @return \Algolia\AlgoliaSearch\Model\Search\SearchQueries[] + */ + public function getRequests() + { + return $this->container['requests'] ?? null; + } + + /** + * Sets requests + * + * @param \Algolia\AlgoliaSearch\Model\Search\SearchQueries[] $requests requests + * + * @return self + */ + public function setRequests($requests) + { + $this->container['requests'] = $requests; + + return $this; + } + + /** + * Gets strategy + * + * @return \Algolia\AlgoliaSearch\Model\Search\SearchStrategy|null + */ + public function getStrategy() + { + return $this->container['strategy'] ?? null; + } + + /** + * Sets strategy + * + * @param \Algolia\AlgoliaSearch\Model\Search\SearchStrategy|null $strategy strategy + * + * @return self + */ + public function setStrategy($strategy) + { + $this->container['strategy'] = $strategy; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchParams.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchParams.php index 2a63605bb1..9d9e65960c 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/SearchParams.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchParams.php @@ -20,6 +20,7 @@ class SearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implements */ protected static $modelTypes = [ 'params' => 'string', + 'query' => 'string', 'similarQuery' => 'string', 'filters' => 'string', 'facetFilters' => '\Algolia\AlgoliaSearch\Model\Search\FacetFilters', @@ -53,7 +54,6 @@ class SearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implements 'enableABTest' => 'bool', 'enableReRanking' => 'bool', 'reRankingApplyFilter' => '\Algolia\AlgoliaSearch\Model\Search\ReRankingApplyFilter', - 'query' => 'string', 'searchableAttributes' => 'string[]', 'attributesForFaceting' => 'string[]', 'unretrievableAttributes' => 'string[]', @@ -107,6 +107,7 @@ class SearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implements */ protected static $modelFormats = [ 'params' => null, + 'query' => null, 'similarQuery' => null, 'filters' => null, 'facetFilters' => null, @@ -140,7 +141,6 @@ class SearchParams extends \Algolia\AlgoliaSearch\Model\AbstractModel implements 'enableABTest' => null, 'enableReRanking' => null, 'reRankingApplyFilter' => null, - 'query' => null, 'searchableAttributes' => null, 'attributesForFaceting' => null, 'unretrievableAttributes' => null, @@ -214,6 +214,7 @@ public static function modelFormats() */ protected static $setters = [ 'params' => 'setParams', + 'query' => 'setQuery', 'similarQuery' => 'setSimilarQuery', 'filters' => 'setFilters', 'facetFilters' => 'setFacetFilters', @@ -247,7 +248,6 @@ public static function modelFormats() 'enableABTest' => 'setEnableABTest', 'enableReRanking' => 'setEnableReRanking', 'reRankingApplyFilter' => 'setReRankingApplyFilter', - 'query' => 'setQuery', 'searchableAttributes' => 'setSearchableAttributes', 'attributesForFaceting' => 'setAttributesForFaceting', 'unretrievableAttributes' => 'setUnretrievableAttributes', @@ -301,6 +301,7 @@ public static function modelFormats() */ protected static $getters = [ 'params' => 'getParams', + 'query' => 'getQuery', 'similarQuery' => 'getSimilarQuery', 'filters' => 'getFilters', 'facetFilters' => 'getFacetFilters', @@ -334,7 +335,6 @@ public static function modelFormats() 'enableABTest' => 'getEnableABTest', 'enableReRanking' => 'getEnableReRanking', 'reRankingApplyFilter' => 'getReRankingApplyFilter', - 'query' => 'getQuery', 'searchableAttributes' => 'getSearchableAttributes', 'attributesForFaceting' => 'getAttributesForFaceting', 'unretrievableAttributes' => 'getUnretrievableAttributes', @@ -418,6 +418,9 @@ public function __construct(array $data = null) if (isset($data['params'])) { $this->container['params'] = $data['params']; } + if (isset($data['query'])) { + $this->container['query'] = $data['query']; + } if (isset($data['similarQuery'])) { $this->container['similarQuery'] = $data['similarQuery']; } @@ -523,9 +526,6 @@ public function __construct(array $data = null) $this->container['reRankingApplyFilter'] = $data['reRankingApplyFilter']; } - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } if (isset($data['searchableAttributes'])) { $this->container['searchableAttributes'] = $data['searchableAttributes']; @@ -716,12 +716,6 @@ public function listInvalidProperties() "invalid value for 'minimumAroundRadius', must be bigger than or equal to 1."; } - if ( - !isset($this->container['query']) || - $this->container['query'] === null - ) { - $invalidProperties[] = "'query' can't be null"; - } if ( isset($this->container['distinct']) && $this->container['distinct'] > 4 @@ -800,6 +794,30 @@ public function setParams($params) return $this; } + /** + * Gets query + * + * @return string|null + */ + public function getQuery() + { + return $this->container['query'] ?? null; + } + + /** + * Sets query + * + * @param string|null $query the text to search in the index + * + * @return self + */ + public function setQuery($query) + { + $this->container['query'] = $query; + + return $this; + } + /** * Gets similarQuery * @@ -1609,30 +1627,6 @@ public function setReRankingApplyFilter($reRankingApplyFilter) return $this; } - /** - * Gets query - * - * @return string - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - /** * Gets searchableAttributes * diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchParamsObject.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchParamsObject.php index bd4f50480d..755b7f3245 100644 --- a/clients/algoliasearch-client-php/lib/Model/Search/SearchParamsObject.php +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchParamsObject.php @@ -19,6 +19,7 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl * @var string[] */ protected static $modelTypes = [ + 'query' => 'string', 'similarQuery' => 'string', 'filters' => 'string', 'facetFilters' => '\Algolia\AlgoliaSearch\Model\Search\FacetFilters', @@ -52,7 +53,6 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl 'enableABTest' => 'bool', 'enableReRanking' => 'bool', 'reRankingApplyFilter' => '\Algolia\AlgoliaSearch\Model\Search\ReRankingApplyFilter', - 'query' => 'string', 'searchableAttributes' => 'string[]', 'attributesForFaceting' => 'string[]', 'unretrievableAttributes' => 'string[]', @@ -105,6 +105,7 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl * @var string[] */ protected static $modelFormats = [ + 'query' => null, 'similarQuery' => null, 'filters' => null, 'facetFilters' => null, @@ -138,7 +139,6 @@ class SearchParamsObject extends \Algolia\AlgoliaSearch\Model\AbstractModel impl 'enableABTest' => null, 'enableReRanking' => null, 'reRankingApplyFilter' => null, - 'query' => null, 'searchableAttributes' => null, 'attributesForFaceting' => null, 'unretrievableAttributes' => null, @@ -211,6 +211,7 @@ public static function modelFormats() * @var string[] */ protected static $setters = [ + 'query' => 'setQuery', 'similarQuery' => 'setSimilarQuery', 'filters' => 'setFilters', 'facetFilters' => 'setFacetFilters', @@ -244,7 +245,6 @@ public static function modelFormats() 'enableABTest' => 'setEnableABTest', 'enableReRanking' => 'setEnableReRanking', 'reRankingApplyFilter' => 'setReRankingApplyFilter', - 'query' => 'setQuery', 'searchableAttributes' => 'setSearchableAttributes', 'attributesForFaceting' => 'setAttributesForFaceting', 'unretrievableAttributes' => 'setUnretrievableAttributes', @@ -297,6 +297,7 @@ public static function modelFormats() * @var string[] */ protected static $getters = [ + 'query' => 'getQuery', 'similarQuery' => 'getSimilarQuery', 'filters' => 'getFilters', 'facetFilters' => 'getFacetFilters', @@ -330,7 +331,6 @@ public static function modelFormats() 'enableABTest' => 'getEnableABTest', 'enableReRanking' => 'getEnableReRanking', 'reRankingApplyFilter' => 'getReRankingApplyFilter', - 'query' => 'getQuery', 'searchableAttributes' => 'getSearchableAttributes', 'attributesForFaceting' => 'getAttributesForFaceting', 'unretrievableAttributes' => 'getUnretrievableAttributes', @@ -411,6 +411,9 @@ public static function getters() */ public function __construct(array $data = null) { + if (isset($data['query'])) { + $this->container['query'] = $data['query']; + } if (isset($data['similarQuery'])) { $this->container['similarQuery'] = $data['similarQuery']; } @@ -516,9 +519,6 @@ public function __construct(array $data = null) $this->container['reRankingApplyFilter'] = $data['reRankingApplyFilter']; } - if (isset($data['query'])) { - $this->container['query'] = $data['query']; - } if (isset($data['searchableAttributes'])) { $this->container['searchableAttributes'] = $data['searchableAttributes']; @@ -709,12 +709,6 @@ public function listInvalidProperties() "invalid value for 'minimumAroundRadius', must be bigger than or equal to 1."; } - if ( - !isset($this->container['query']) || - $this->container['query'] === null - ) { - $invalidProperties[] = "'query' can't be null"; - } if ( isset($this->container['distinct']) && $this->container['distinct'] > 4 @@ -769,6 +763,30 @@ public function valid() return count($this->listInvalidProperties()) === 0; } + /** + * Gets query + * + * @return string|null + */ + public function getQuery() + { + return $this->container['query'] ?? null; + } + + /** + * Sets query + * + * @param string|null $query the text to search in the index + * + * @return self + */ + public function setQuery($query) + { + $this->container['query'] = $query; + + return $this; + } + /** * Gets similarQuery * @@ -1578,30 +1596,6 @@ public function setReRankingApplyFilter($reRankingApplyFilter) return $this; } - /** - * Gets query - * - * @return string - */ - public function getQuery() - { - return $this->container['query'] ?? null; - } - - /** - * Sets query - * - * @param string $query the text to search in the index - * - * @return self - */ - public function setQuery($query) - { - $this->container['query'] = $query; - - return $this; - } - /** * Gets searchableAttributes * diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php new file mode 100644 index 0000000000..faf4009fc2 --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchQueries.php @@ -0,0 +1,340 @@ + 'string', + 'query' => 'string', + 'type' => '\Algolia\AlgoliaSearch\Model\Search\SearchType', + 'facet' => 'string', + 'params' => '\Algolia\AlgoliaSearch\Model\Search\SearchParams', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $modelFormats = [ + 'indexName' => null, + 'query' => null, + 'type' => null, + 'facet' => null, + 'params' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function modelTypes() + { + return self::$modelTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function modelFormats() + { + return self::$modelFormats; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'indexName' => 'setIndexName', + 'query' => 'setQuery', + 'type' => 'setType', + 'facet' => 'setFacet', + 'params' => 'setParams', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'indexName' => 'getIndexName', + 'query' => 'getQuery', + 'type' => 'getType', + 'facet' => 'getFacet', + 'params' => 'getParams', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + */ + public function __construct(array $data = null) + { + if (isset($data['indexName'])) { + $this->container['indexName'] = $data['indexName']; + } + if (isset($data['query'])) { + $this->container['query'] = $data['query']; + } + if (isset($data['type'])) { + $this->container['type'] = $data['type']; + } + if (isset($data['facet'])) { + $this->container['facet'] = $data['facet']; + } + if (isset($data['params'])) { + $this->container['params'] = $data['params']; + } + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ( + !isset($this->container['indexName']) || + $this->container['indexName'] === null + ) { + $invalidProperties[] = "'indexName' can't be null"; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Gets indexName + * + * @return string + */ + public function getIndexName() + { + return $this->container['indexName'] ?? null; + } + + /** + * Sets indexName + * + * @param string $indexName the Algolia index name + * + * @return self + */ + public function setIndexName($indexName) + { + $this->container['indexName'] = $indexName; + + return $this; + } + + /** + * Gets query + * + * @return string|null + */ + public function getQuery() + { + return $this->container['query'] ?? null; + } + + /** + * Sets query + * + * @param string|null $query the text to search in the index + * + * @return self + */ + public function setQuery($query) + { + $this->container['query'] = $query; + + return $this; + } + + /** + * Gets type + * + * @return \Algolia\AlgoliaSearch\Model\Search\SearchType|null + */ + public function getType() + { + return $this->container['type'] ?? null; + } + + /** + * Sets type + * + * @param \Algolia\AlgoliaSearch\Model\Search\SearchType|null $type type + * + * @return self + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets facet + * + * @return string|null + */ + public function getFacet() + { + return $this->container['facet'] ?? null; + } + + /** + * Sets facet + * + * @param string|null $facet the `facet` name + * + * @return self + */ + public function setFacet($facet) + { + $this->container['facet'] = $facet; + + return $this; + } + + /** + * Gets params + * + * @return \Algolia\AlgoliaSearch\Model\Search\SearchParams|null + */ + public function getParams() + { + return $this->container['params'] ?? null; + } + + /** + * Sets params + * + * @param \Algolia\AlgoliaSearch\Model\Search\SearchParams|null $params params + * + * @return self + */ + public function setParams($params) + { + $this->container['params'] = $params; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchResponses.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchResponses.php new file mode 100644 index 0000000000..2b0274fcbf --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchResponses.php @@ -0,0 +1,209 @@ + '\Algolia\AlgoliaSearch\Model\Search\SearchResponse[]', + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $modelFormats = [ + 'results' => null, + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function modelTypes() + { + return self::$modelTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function modelFormats() + { + return self::$modelFormats; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'results' => 'setResults', + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'results' => 'getResults', + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + */ + public function __construct(array $data = null) + { + if (isset($data['results'])) { + $this->container['results'] = $data['results']; + } + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + /** + * Gets results + * + * @return \Algolia\AlgoliaSearch\Model\Search\SearchResponse[]|null + */ + public function getResults() + { + return $this->container['results'] ?? null; + } + + /** + * Sets results + * + * @param \Algolia\AlgoliaSearch\Model\Search\SearchResponse[]|null $results results + * + * @return self + */ + public function setResults($results) + { + $this->container['results'] = $results; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param int $offset Offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param int $offset Offset + * + * @return mixed|null + */ + public function offsetGet($offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param int $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} diff --git a/clients/algoliasearch-client-php/lib/Model/Search/SearchStrategy.php b/clients/algoliasearch-client-php/lib/Model/Search/SearchStrategy.php new file mode 100644 index 0000000000..c39f0a4ef4 --- /dev/null +++ b/clients/algoliasearch-client-php/lib/Model/Search/SearchStrategy.php @@ -0,0 +1,29 @@ +- @@ -371,18 +377,6 @@ components: default: true reRankingApplyFilter: $ref: '#/components/schemas/reRankingApplyFilter' - query: - type: string - description: The text to search in the index. - default: '' - requiredSearchParams: - type: object - additionalProperties: false - required: - - query - properties: - query: - $ref: '#/components/schemas/query' hitsPerPage: type: integer description: Set the number of hits per page. @@ -710,7 +704,6 @@ components: searchParamsObject: allOf: - $ref: '#/components/schemas/baseSearchParams' - - $ref: '#/components/schemas/requiredSearchParams' - $ref: '#/components/schemas/indexSettingsAsSearchParams' searchParams: oneOf: @@ -1003,7 +996,7 @@ components: type: array items: $ref: '#/components/schemas/hit' - searchResponse: + SearchResponse: allOf: - $ref: '#/components/schemas/baseSearchResponse' - $ref: '#/components/schemas/searchHits' @@ -1011,7 +1004,7 @@ components: type: string example: products description: The Algolia index name. - multipleQueriesType: + searchType: type: string enum: - default @@ -1020,7 +1013,7 @@ components: description: >- Perform a search query with `default`, will search for facet values if `facet` is given. - multipleQueriesStrategy: + searchStrategy: type: string enum: - none @@ -2022,57 +2015,27 @@ paths: $ref: '#/components/responses/IndexNotFound' tags: - algoliasearch-lite - /1/indexes/{indexName}/query: - post: - tags: - - algoliasearch-lite - operationId: search - summary: Search in an index. - description: Perform a search operation targeting one specific index. - parameters: - - $ref: '#/components/parameters/IndexName' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/searchParams' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/searchResponse' - '400': - $ref: '#/components/responses/BadRequest' - '402': - $ref: '#/components/responses/FeatureNotEnabled' - '403': - $ref: '#/components/responses/MethodNotAllowed' - '404': - $ref: '#/components/responses/IndexNotFound' /1/indexes/*/queries: post: tags: - algoliasearch-lite - operationId: multipleQueries + operationId: search summary: Search multiple indices. description: Perform a search operation targeting one or many indices. requestBody: required: true - description: The `multipleQueries` requests and strategy. + description: The `search` requests and strategy. content: application/json: schema: - title: multipleQueriesParams + title: searchMethodParams type: object additionalProperties: false properties: requests: type: array items: - title: multipleQueries + title: searchQueries type: object additionalProperties: false properties: @@ -2081,17 +2044,16 @@ paths: query: $ref: '#/components/schemas/query' type: - $ref: '#/components/schemas/multipleQueriesType' + $ref: '#/components/schemas/searchType' facet: type: string description: The `facet` name. params: - type: string - description: A query string of search parameters. + $ref: '#/components/schemas/searchParams' required: - indexName strategy: - $ref: '#/components/schemas/multipleQueriesStrategy' + $ref: '#/components/schemas/searchStrategy' required: - requests responses: @@ -2100,14 +2062,14 @@ paths: content: application/json: schema: - title: multipleQueriesResponse + title: searchResponses type: object additionalProperties: false properties: results: type: array items: - $ref: '#/components/schemas/searchResponse' + $ref: '#/components/schemas/SearchResponse' '400': $ref: '#/components/responses/BadRequest' '402': diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 10328a1c3f..d40658e9b0 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -50,6 +50,10 @@ components: type: string example: products description: The Algolia index name. + query: + type: string + description: The text to search in the index. + default: '' searchFiltersArrayString: type: array items: @@ -107,6 +111,8 @@ components: type: object additionalProperties: false properties: + query: + $ref: '#/components/schemas/query' similarQuery: type: string description: >- @@ -259,18 +265,6 @@ components: default: true reRankingApplyFilter: $ref: '#/components/schemas/reRankingApplyFilter' - query: - type: string - description: The text to search in the index. - default: '' - requiredSearchParams: - type: object - additionalProperties: false - required: - - query - properties: - query: - $ref: '#/components/schemas/query' hitsPerPage: type: integer description: Set the number of hits per page. @@ -598,7 +592,6 @@ components: searchParamsObject: allOf: - $ref: '#/components/schemas/baseSearchParams' - - $ref: '#/components/schemas/requiredSearchParams' - $ref: '#/components/schemas/indexSettingsAsSearchParams' baseRecommendRequest: type: object diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 27278c1c6f..e06a7f5671 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -162,6 +162,10 @@ components: properties: params: $ref: '#/components/schemas/paramsAsString' + query: + type: string + description: The text to search in the index. + default: '' searchFiltersArrayString: type: array items: @@ -219,6 +223,8 @@ components: type: object additionalProperties: false properties: + query: + $ref: '#/components/schemas/query' similarQuery: type: string description: >- @@ -371,18 +377,6 @@ components: default: true reRankingApplyFilter: $ref: '#/components/schemas/reRankingApplyFilter' - query: - type: string - description: The text to search in the index. - default: '' - requiredSearchParams: - type: object - additionalProperties: false - required: - - query - properties: - query: - $ref: '#/components/schemas/query' hitsPerPage: type: integer description: Set the number of hits per page. @@ -710,7 +704,6 @@ components: searchParamsObject: allOf: - $ref: '#/components/schemas/baseSearchParams' - - $ref: '#/components/schemas/requiredSearchParams' - $ref: '#/components/schemas/indexSettingsAsSearchParams' searchParams: oneOf: @@ -1003,7 +996,7 @@ components: type: array items: $ref: '#/components/schemas/hit' - searchResponse: + SearchResponse: allOf: - $ref: '#/components/schemas/baseSearchResponse' - $ref: '#/components/schemas/searchHits' @@ -1011,7 +1004,7 @@ components: type: string example: products description: The Algolia index name. - multipleQueriesType: + searchType: type: string enum: - default @@ -1020,7 +1013,7 @@ components: description: >- Perform a search query with `default`, will search for facet values if `facet` is given. - multipleQueriesStrategy: + searchStrategy: type: string enum: - none @@ -2104,8 +2097,8 @@ paths: post: tags: - search - operationId: search - summary: Search in an index. + operationId: searchSingleIndex + summary: Search in a single index. description: Perform a search operation targeting one specific index. parameters: - $ref: '#/components/parameters/IndexName' @@ -2121,7 +2114,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/searchResponse' + $ref: '#/components/schemas/SearchResponse' '400': $ref: '#/components/responses/BadRequest' '402': @@ -2134,23 +2127,23 @@ paths: post: tags: - search - operationId: multipleQueries + operationId: search summary: Search multiple indices. description: Perform a search operation targeting one or many indices. requestBody: required: true - description: The `multipleQueries` requests and strategy. + description: The `search` requests and strategy. content: application/json: schema: - title: multipleQueriesParams + title: searchMethodParams type: object additionalProperties: false properties: requests: type: array items: - title: multipleQueries + title: searchQueries type: object additionalProperties: false properties: @@ -2159,17 +2152,16 @@ paths: query: $ref: '#/components/schemas/query' type: - $ref: '#/components/schemas/multipleQueriesType' + $ref: '#/components/schemas/searchType' facet: type: string description: The `facet` name. params: - type: string - description: A query string of search parameters. + $ref: '#/components/schemas/searchParams' required: - indexName strategy: - $ref: '#/components/schemas/multipleQueriesStrategy' + $ref: '#/components/schemas/searchStrategy' required: - requests responses: @@ -2178,14 +2170,14 @@ paths: content: application/json: schema: - title: multipleQueriesResponse + title: searchResponses type: object additionalProperties: false properties: results: type: array items: - $ref: '#/components/schemas/searchResponse' + $ref: '#/components/schemas/SearchResponse' '400': $ref: '#/components/responses/BadRequest' '402': diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index f09811d14d..1c86485e6a 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -1189,102 +1189,6 @@ void multipleBatchTest0() { }); } - @Test - @DisplayName("multipleQueries for a single request with minimal parameters") - void multipleQueriesTest0() { - MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleQueries requests_02 = new MultipleQueries(); - { - String indexName3 = "theIndexName"; - requests_02.setIndexName(indexName3); - } - requests1.add(requests_02); - } - multipleQueriesParams0.setRequests(requests1); - MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( - "stopIfEnoughMatches" - ); - multipleQueriesParams0.setStrategy(strategy1); - } - - assertDoesNotThrow(() -> { - client.multipleQueries(multipleQueriesParams0); - }); - EchoResponse req = requester.getLastEchoResponse(); - - assertEquals(req.path, "/1/indexes/*/queries"); - assertEquals(req.method, "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"theIndexName\"}],\"strategy\":\"stopIfEnoughMatches\"}", - req.body, - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("multipleQueries for multiple requests with all parameters") - void multipleQueriesTest1() { - MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleQueries requests_02 = new MultipleQueries(); - { - String indexName3 = "theIndexName"; - requests_02.setIndexName(indexName3); - String query3 = "test"; - requests_02.setQuery(query3); - MultipleQueriesType type3 = MultipleQueriesType.fromValue("facet"); - requests_02.setType(type3); - String facet3 = "theFacet"; - requests_02.setFacet(facet3); - String params3 = "testParam"; - requests_02.setParams(params3); - } - requests1.add(requests_02); - MultipleQueries requests_12 = new MultipleQueries(); - { - String indexName3 = "theIndexName"; - requests_12.setIndexName(indexName3); - String query3 = "test"; - requests_12.setQuery(query3); - MultipleQueriesType type3 = MultipleQueriesType.fromValue("default"); - requests_12.setType(type3); - String params3 = "testParam"; - requests_12.setParams(params3); - } - requests1.add(requests_12); - } - multipleQueriesParams0.setRequests(requests1); - MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( - "stopIfEnoughMatches" - ); - multipleQueriesParams0.setStrategy(strategy1); - } - - assertDoesNotThrow(() -> { - client.multipleQueries(multipleQueriesParams0); - }); - EchoResponse req = requester.getLastEchoResponse(); - - assertEquals(req.path, "/1/indexes/*/queries"); - assertEquals(req.method, "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"},{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"default\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", - req.body, - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test @DisplayName("operationIndex") void operationIndexTest0() { @@ -2244,29 +2148,33 @@ void saveSynonymsTest0() { } @Test - @DisplayName("search with minimal parameters") + @DisplayName("search for a single request with minimal parameters") void searchTest0() { - String indexName0 = "indexName"; - SearchParamsObject searchParams0 = new SearchParamsObject(); + SearchMethodParams searchMethodParams0 = new SearchMethodParams(); { - String query1 = "myQuery"; - searchParams0.setQuery(query1); + List requests1 = new ArrayList<>(); + { + SearchQueries requests_02 = new SearchQueries(); + { + String indexName3 = "theIndexName"; + requests_02.setIndexName(indexName3); + } + requests1.add(requests_02); + } + searchMethodParams0.setRequests(requests1); } assertDoesNotThrow(() -> { - client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); + client.search(searchMethodParams0); }); EchoResponse req = requester.getLastEchoResponse(); - assertEquals(req.path, "/1/indexes/indexName/query"); + assertEquals(req.path, "/1/indexes/*/queries"); assertEquals(req.method, "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"myQuery\"}", + "{\"requests\":[{\"indexName\":\"theIndexName\"}]}", req.body, JSONCompareMode.STRICT_ORDER ); @@ -2274,35 +2182,117 @@ void searchTest0() { } @Test - @DisplayName("search with facetFilters") + @DisplayName("search for a single request with all parameters") void searchTest1() { - String indexName0 = "indexName"; - SearchParamsObject searchParams0 = new SearchParamsObject(); + SearchMethodParams searchMethodParams0 = new SearchMethodParams(); { - String query1 = "myQuery"; - searchParams0.setQuery(query1); - List facetFilters1 = new ArrayList<>(); + List requests1 = new ArrayList<>(); { - String facetFilters_02 = "tags:algolia"; - facetFilters1.add(facetFilters_02); + SearchQueries requests_02 = new SearchQueries(); + { + String indexName3 = "theIndexName"; + requests_02.setIndexName(indexName3); + String query3 = "test"; + requests_02.setQuery(query3); + SearchType type3 = SearchType.fromValue("facet"); + requests_02.setType(type3); + String facet3 = "theFacet"; + requests_02.setFacet(facet3); + SearchParamsObject params3 = new SearchParamsObject(); + { + int hitsPerPage4 = 50; + params3.setHitsPerPage(hitsPerPage4); + } + requests_02.setParams(SearchParams.ofSearchParamsObject(params3)); + } + requests1.add(requests_02); } - searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); + searchMethodParams0.setRequests(requests1); + SearchStrategy strategy1 = SearchStrategy.fromValue( + "stopIfEnoughMatches" + ); + searchMethodParams0.setStrategy(strategy1); } assertDoesNotThrow(() -> { - client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) + client.search(searchMethodParams0); + }); + EchoResponse req = requester.getLastEchoResponse(); + + assertEquals(req.path, "/1/indexes/*/queries"); + assertEquals(req.method, "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":{\"hitsPerPage\":50}}],\"strategy\":\"stopIfEnoughMatches\"}", + req.body, + JSONCompareMode.STRICT_ORDER ); }); + } + + @Test + @DisplayName( + "search for multiple requests in multiple indices with all parameters" + ) + void searchTest2() { + SearchMethodParams searchMethodParams0 = new SearchMethodParams(); + { + List requests1 = new ArrayList<>(); + { + SearchQueries requests_02 = new SearchQueries(); + { + String indexName3 = "theIndexName"; + requests_02.setIndexName(indexName3); + String query3 = "test"; + requests_02.setQuery(query3); + SearchType type3 = SearchType.fromValue("facet"); + requests_02.setType(type3); + String facet3 = "theFacet"; + requests_02.setFacet(facet3); + SearchParamsObject params3 = new SearchParamsObject(); + { + int hitsPerPage4 = 50; + params3.setHitsPerPage(hitsPerPage4); + } + requests_02.setParams(SearchParams.ofSearchParamsObject(params3)); + } + requests1.add(requests_02); + SearchQueries requests_12 = new SearchQueries(); + { + String indexName3 = "theIndexName2"; + requests_12.setIndexName(indexName3); + String query3 = "test"; + requests_12.setQuery(query3); + SearchType type3 = SearchType.fromValue("default"); + requests_12.setType(type3); + SearchParamsObject params3 = new SearchParamsObject(); + { + int hitsPerPage4 = 100; + params3.setHitsPerPage(hitsPerPage4); + } + requests_12.setParams(SearchParams.ofSearchParamsObject(params3)); + } + requests1.add(requests_12); + } + searchMethodParams0.setRequests(requests1); + SearchStrategy strategy1 = SearchStrategy.fromValue( + "stopIfEnoughMatches" + ); + searchMethodParams0.setStrategy(strategy1); + } + + assertDoesNotThrow(() -> { + client.search(searchMethodParams0); + }); EchoResponse req = requester.getLastEchoResponse(); - assertEquals(req.path, "/1/indexes/indexName/query"); + assertEquals(req.path, "/1/indexes/*/queries"); assertEquals(req.method, "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":{\"hitsPerPage\":50}},{\"indexName\":\"theIndexName2\",\"query\":\"test\",\"type\":\"default\",\"params\":{\"hitsPerPage\":100}}],\"strategy\":\"stopIfEnoughMatches\"}", req.body, JSONCompareMode.STRICT_ORDER ); @@ -2453,6 +2443,72 @@ void searchRulesTest0() { }); } + @Test + @DisplayName("search with minimal parameters") + void searchSingleIndexTest0() { + String indexName0 = "indexName"; + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "myQuery"; + searchParams0.setQuery(query1); + } + + assertDoesNotThrow(() -> { + client.searchSingleIndex( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); + }); + EchoResponse req = requester.getLastEchoResponse(); + + assertEquals(req.path, "/1/indexes/indexName/query"); + assertEquals(req.method, "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"myQuery\"}", + req.body, + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("search with facetFilters") + void searchSingleIndexTest1() { + String indexName0 = "indexName"; + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "myQuery"; + searchParams0.setQuery(query1); + List facetFilters1 = new ArrayList<>(); + { + String facetFilters_02 = "tags:algolia"; + facetFilters1.add(facetFilters_02); + } + searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); + } + + assertDoesNotThrow(() -> { + client.searchSingleIndex( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); + }); + EchoResponse req = requester.getLastEchoResponse(); + + assertEquals(req.path, "/1/indexes/indexName/query"); + assertEquals(req.method, "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", + req.body, + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test @DisplayName("searchSynonyms") void searchSynonymsTest0() { diff --git a/tests/output/javascript/src/client/search.test.ts b/tests/output/javascript/src/client/search.test.ts index 8cf4a96856..bc06404ae9 100644 --- a/tests/output/javascript/src/client/search.test.ts +++ b/tests/output/javascript/src/client/search.test.ts @@ -18,7 +18,7 @@ describe('api', () => { let actual; - actual = $client.search({ indexName: 'my-index', searchParams: {} }); + actual = $client.search({ requests: [{ indexName: 'my-index' }] }); if (actual instanceof Promise) { actual = await actual; @@ -35,7 +35,7 @@ describe('api', () => { let actual; - actual = $client.search({ indexName: 'my-index', searchParams: {} }); + actual = $client.search({ requests: [{ indexName: 'my-index' }] }); if (actual instanceof Promise) { actual = await actual; @@ -52,7 +52,7 @@ describe('api', () => { let actual; - actual = $client.search({ indexName: 'my-index', searchParams: {} }); + actual = $client.search({ requests: [{ indexName: 'my-index' }] }); if (actual instanceof Promise) { actual = await actual; diff --git a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts index eee80dfd66..2c99aa5ea4 100644 --- a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts +++ b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts @@ -12,66 +12,6 @@ const client = algoliasearchLiteClient(appId, apiKey, { requester: echoRequester(), }); -describe('multipleQueries', () => { - test('multipleQueries for a single request with minimal parameters', async () => { - const req = (await client.multipleQueries({ - requests: [{ indexName: 'theIndexName' }], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'theIndexName' }], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('multipleQueries for multiple requests with all parameters', async () => { - const req = (await client.multipleQueries({ - requests: [ - { - indexName: 'theIndexName', - query: 'test', - type: 'facet', - facet: 'theFacet', - params: 'testParam', - }, - { - indexName: 'theIndexName', - query: 'test', - type: 'default', - params: 'testParam', - }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - query: 'test', - type: 'facet', - facet: 'theFacet', - params: 'testParam', - }, - { - indexName: 'theIndexName', - query: 'test', - type: 'default', - params: 'testParam', - }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - describe('post', () => { test('allow post method for a custom path with minimal parameters', async () => { const req = (await client.post({ @@ -301,29 +241,87 @@ describe('post', () => { }); describe('search', () => { - test('search with minimal parameters', async () => { + test('search for a single request with minimal parameters', async () => { const req = (await client.search({ - indexName: 'indexName', - searchParams: { query: 'myQuery' }, + requests: [{ indexName: 'theIndexName' }], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.path).toEqual('/1/indexes/*/queries'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'myQuery' }); + expect(req.data).toEqual({ requests: [{ indexName: 'theIndexName' }] }); expect(req.searchParams).toStrictEqual(undefined); }); - test('search with facetFilters', async () => { + test('search for a single request with all parameters', async () => { const req = (await client.search({ - indexName: 'indexName', - searchParams: { query: 'myQuery', facetFilters: ['tags:algolia'] }, + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + ], + strategy: 'stopIfEnoughMatches', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.path).toEqual('/1/indexes/*/queries'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - query: 'myQuery', - facetFilters: ['tags:algolia'], + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + ], + strategy: 'stopIfEnoughMatches', + }); + expect(req.searchParams).toStrictEqual(undefined); + }); + + test('search for multiple requests in multiple indices with all parameters', async () => { + const req = (await client.search({ + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + { + indexName: 'theIndexName2', + query: 'test', + type: 'default', + params: { hitsPerPage: 100 }, + }, + ], + strategy: 'stopIfEnoughMatches', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/*/queries'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + { + indexName: 'theIndexName2', + query: 'test', + type: 'default', + params: { hitsPerPage: 100 }, + }, + ], + strategy: 'stopIfEnoughMatches', }); expect(req.searchParams).toStrictEqual(undefined); }); diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index be2a69dd61..0624515da7 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -748,66 +748,6 @@ describe('multipleBatch', () => { }); }); -describe('multipleQueries', () => { - test('multipleQueries for a single request with minimal parameters', async () => { - const req = (await client.multipleQueries({ - requests: [{ indexName: 'theIndexName' }], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ indexName: 'theIndexName' }], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); - - test('multipleQueries for multiple requests with all parameters', async () => { - const req = (await client.multipleQueries({ - requests: [ - { - indexName: 'theIndexName', - query: 'test', - type: 'facet', - facet: 'theFacet', - params: 'testParam', - }, - { - indexName: 'theIndexName', - query: 'test', - type: 'default', - params: 'testParam', - }, - ], - strategy: 'stopIfEnoughMatches', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/*/queries'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - indexName: 'theIndexName', - query: 'test', - type: 'facet', - facet: 'theFacet', - params: 'testParam', - }, - { - indexName: 'theIndexName', - query: 'test', - type: 'default', - params: 'testParam', - }, - ], - strategy: 'stopIfEnoughMatches', - }); - expect(req.searchParams).toStrictEqual(undefined); - }); -}); - describe('operationIndex', () => { test('operationIndex', async () => { const req = (await client.operationIndex({ @@ -1251,29 +1191,87 @@ describe('saveSynonyms', () => { }); describe('search', () => { - test('search with minimal parameters', async () => { + test('search for a single request with minimal parameters', async () => { const req = (await client.search({ - indexName: 'indexName', - searchParams: { query: 'myQuery' }, + requests: [{ indexName: 'theIndexName' }], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.path).toEqual('/1/indexes/*/queries'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'myQuery' }); + expect(req.data).toEqual({ requests: [{ indexName: 'theIndexName' }] }); expect(req.searchParams).toStrictEqual(undefined); }); - test('search with facetFilters', async () => { + test('search for a single request with all parameters', async () => { const req = (await client.search({ - indexName: 'indexName', - searchParams: { query: 'myQuery', facetFilters: ['tags:algolia'] }, + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + ], + strategy: 'stopIfEnoughMatches', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.path).toEqual('/1/indexes/*/queries'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - query: 'myQuery', - facetFilters: ['tags:algolia'], + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + ], + strategy: 'stopIfEnoughMatches', + }); + expect(req.searchParams).toStrictEqual(undefined); + }); + + test('search for multiple requests in multiple indices with all parameters', async () => { + const req = (await client.search({ + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + { + indexName: 'theIndexName2', + query: 'test', + type: 'default', + params: { hitsPerPage: 100 }, + }, + ], + strategy: 'stopIfEnoughMatches', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/*/queries'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: { hitsPerPage: 50 }, + }, + { + indexName: 'theIndexName2', + query: 'test', + type: 'default', + params: { hitsPerPage: 100 }, + }, + ], + strategy: 'stopIfEnoughMatches', }); expect(req.searchParams).toStrictEqual(undefined); }); @@ -1364,6 +1362,35 @@ describe('searchRules', () => { }); }); +describe('searchSingleIndex', () => { + test('search with minimal parameters', async () => { + const req = (await client.searchSingleIndex({ + indexName: 'indexName', + searchParams: { query: 'myQuery' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ query: 'myQuery' }); + expect(req.searchParams).toStrictEqual(undefined); + }); + + test('search with facetFilters', async () => { + const req = (await client.searchSingleIndex({ + indexName: 'indexName', + searchParams: { query: 'myQuery', facetFilters: ['tags:algolia'] }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + query: 'myQuery', + facetFilters: ['tags:algolia'], + }); + expect(req.searchParams).toStrictEqual(undefined); + }); +}); + describe('searchSynonyms', () => { test('searchSynonyms', async () => { const req = (await client.searchSynonyms({ diff --git a/tests/output/php/src/methods/requests/SearchTest.php b/tests/output/php/src/methods/requests/SearchTest.php index 833f648077..16cd5e6531 100644 --- a/tests/output/php/src/methods/requests/SearchTest.php +++ b/tests/output/php/src/methods/requests/SearchTest.php @@ -1067,67 +1067,6 @@ public function testMultipleBatch0() ]); } - /** - * Test case for MultipleQueries - * multipleQueries for a single request with minimal parameters - */ - public function testMultipleQueries0() - { - $client = $this->getClient(); - $client->multipleQueries([ - 'requests' => [['indexName' => 'theIndexName']], - 'strategy' => 'stopIfEnoughMatches', - ]); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/*/queries', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"indexName\":\"theIndexName\"}],\"strategy\":\"stopIfEnoughMatches\"}" - ), - ], - ]); - } - - /** - * Test case for MultipleQueries - * multipleQueries for multiple requests with all parameters - */ - public function testMultipleQueries1() - { - $client = $this->getClient(); - $client->multipleQueries([ - 'requests' => [ - [ - 'indexName' => 'theIndexName', - 'query' => 'test', - 'type' => 'facet', - 'facet' => 'theFacet', - 'params' => 'testParam', - ], - - [ - 'indexName' => 'theIndexName', - 'query' => 'test', - 'type' => 'default', - 'params' => 'testParam', - ], - ], - 'strategy' => 'stopIfEnoughMatches', - ]); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/*/queries', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"},{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"default\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}" - ), - ], - ]); - } - /** * Test case for OperationIndex * operationIndex @@ -1769,43 +1708,88 @@ public function testSaveSynonyms0() /** * Test case for Search - * search with minimal parameters + * search for a single request with minimal parameters */ public function testSearch0() { $client = $this->getClient(); - $client->search( - 'indexName', - ['query' => 'myQuery'] - ); + $client->search(['requests' => [['indexName' => 'theIndexName']]]); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/query', + 'path' => '/1/indexes/*/queries', 'method' => 'POST', - 'body' => json_decode("{\"query\":\"myQuery\"}"), + 'body' => json_decode( + "{\"requests\":[{\"indexName\":\"theIndexName\"}]}" + ), ], ]); } /** * Test case for Search - * search with facetFilters + * search for a single request with all parameters */ public function testSearch1() { $client = $this->getClient(); - $client->search( - 'indexName', - ['query' => 'myQuery', 'facetFilters' => ['tags:algolia']] - ); + $client->search([ + 'requests' => [ + [ + 'indexName' => 'theIndexName', + 'query' => 'test', + 'type' => 'facet', + 'facet' => 'theFacet', + 'params' => ['hitsPerPage' => 50], + ], + ], + 'strategy' => 'stopIfEnoughMatches', + ]); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/query', + 'path' => '/1/indexes/*/queries', 'method' => 'POST', 'body' => json_decode( - "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}" + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":{\"hitsPerPage\":50}}],\"strategy\":\"stopIfEnoughMatches\"}" + ), + ], + ]); + } + + /** + * Test case for Search + * search for multiple requests in multiple indices with all parameters + */ + public function testSearch2() + { + $client = $this->getClient(); + $client->search([ + 'requests' => [ + [ + 'indexName' => 'theIndexName', + 'query' => 'test', + 'type' => 'facet', + 'facet' => 'theFacet', + 'params' => ['hitsPerPage' => 50], + ], + + [ + 'indexName' => 'theIndexName2', + 'query' => 'test', + 'type' => 'default', + 'params' => ['hitsPerPage' => 100], + ], + ], + 'strategy' => 'stopIfEnoughMatches', + ]); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/*/queries', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":{\"hitsPerPage\":50}},{\"indexName\":\"theIndexName2\",\"query\":\"test\",\"type\":\"default\",\"params\":{\"hitsPerPage\":100}}],\"strategy\":\"stopIfEnoughMatches\"}" ), ], ]); @@ -1929,6 +1913,50 @@ public function testSearchRules0() ]); } + /** + * Test case for SearchSingleIndex + * search with minimal parameters + */ + public function testSearchSingleIndex0() + { + $client = $this->getClient(); + $client->searchSingleIndex( + 'indexName', + ['query' => 'myQuery'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/query', + 'method' => 'POST', + 'body' => json_decode("{\"query\":\"myQuery\"}"), + ], + ]); + } + + /** + * Test case for SearchSingleIndex + * search with facetFilters + */ + public function testSearchSingleIndex1() + { + $client = $this->getClient(); + $client->searchSingleIndex( + 'indexName', + ['query' => 'myQuery', 'facetFilters' => ['tags:algolia']] + ); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/query', + 'method' => 'POST', + 'body' => json_decode( + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}" + ), + ], + ]); + } + /** * Test case for SearchSynonyms * searchSynonyms From 96fddef82f97f62b3d7486155bc7638defd73074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Thu, 19 May 2022 16:19:28 +0200 Subject: [PATCH 8/8] fix(scripts): codegen cleanup (#517) --- .github/workflows/codegen.yml | 1 + scripts/ci/codegen/__tests__/codegen.test.ts | 49 ++++++++++++++----- scripts/ci/codegen/text.ts | 5 +- scripts/ci/codegen/upsertGenerationComment.ts | 10 +++- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 0cf464513b..787da8c56a 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -25,6 +25,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }} PR_NUMBER: ${{ github.event.number }} + HEAD_BRANCH: ${{ github.head_ref }} cleanup: runs-on: ubuntu-20.04 diff --git a/scripts/ci/codegen/__tests__/codegen.test.ts b/scripts/ci/codegen/__tests__/codegen.test.ts index 5ab99b270c..6d482f4e7b 100644 --- a/scripts/ci/codegen/__tests__/codegen.test.ts +++ b/scripts/ci/codegen/__tests__/codegen.test.ts @@ -1,17 +1,12 @@ -import { MAIN_BRANCH } from '../../../common'; +import * as common from '../../../common'; import { cleanGeneratedBranch } from '../cleanGeneratedBranch'; import { pushGeneratedCode } from '../pushGeneratedCode'; import commentText from '../text'; import { - getCommentBody, upsertGenerationComment, + getCommentBody, } from '../upsertGenerationComment'; -jest.mock('../../../common', () => ({ - ...(jest.requireActual('../../../common') as any), - run: jest.fn().mockResolvedValue('mocked'), -})); - describe('codegen', () => { describe('cleanGeneratedBranch', () => { it('throws without parameters', async () => { @@ -68,13 +63,41 @@ describe('codegen', () => { `); }); - it('returns the right comment for a `cleanup` trigger', async () => { - expect(await getCommentBody('cleanup')).toMatchInlineSnapshot(` - "### ✗ The generated branch has been deleted. + describe('cleanup', () => { + let mockedResolvedValue: string; + beforeEach(() => { + jest.spyOn(common, 'run').mockImplementation(() => { + return Promise.resolve(mockedResolvedValue); + }); + }); + + afterEach(() => { + jest.spyOn(common, 'run').mockRestore(); + }); + + afterEach(() => {}); + it('returns the right comment for a `cleanup` trigger', async () => { + mockedResolvedValue = 'mocked'; - If the PR has been merged, you can check the generated code on the [\`${MAIN_BRANCH}\` branch](https://github.com/algolia/api-clients-automation/tree/${MAIN_BRANCH}). - You can still access [the last generated commit](https://github.com/algolia/api-clients-automation/commit/mocked)." - `); + expect(await getCommentBody('cleanup')).toMatchInlineSnapshot(` + "### ✗ The generated branch has been deleted. + + If the PR has been merged, you can check the generated code on the [\`${common.MAIN_BRANCH}\` branch](https://github.com/algolia/api-clients-automation/tree/${common.MAIN_BRANCH}). + You can still access the code generated on \`mocked\` via [this commit](https://github.com/algolia/api-clients-automation/commit/mocked)." + `); + }); + + it('fallbacks to the env variable HEAD_BRANCH if found when we are on `main`', async () => { + process.env.HEAD_BRANCH = 'myFakeBranch'; + mockedResolvedValue = 'main'; + + expect(await getCommentBody('cleanup')).toMatchInlineSnapshot(` + "### ✗ The generated branch has been deleted. + + If the PR has been merged, you can check the generated code on the [\`${common.MAIN_BRANCH}\` branch](https://github.com/algolia/api-clients-automation/tree/${common.MAIN_BRANCH}). + You can still access the code generated on \`generated/myFakeBranch\` via [this commit](https://github.com/algolia/api-clients-automation/commit/main)." + `); + }); }); describe('text', () => { diff --git a/scripts/ci/codegen/text.ts b/scripts/ci/codegen/text.ts index 6ac416e138..7de7ddb749 100644 --- a/scripts/ci/codegen/text.ts +++ b/scripts/ci/codegen/text.ts @@ -15,9 +15,10 @@ export default { cleanup: { header: '### ✗ The generated branch has been deleted.', body: ( - generatedCommit: string + generatedCommit: string, + branch: string ): string => `If the PR has been merged, you can check the generated code on the [\`${MAIN_BRANCH}\` branch](${REPO_URL}/tree/${MAIN_BRANCH}). -You can still access [the last generated commit](${REPO_URL}/commit/${generatedCommit}).`, +You can still access the code generated on \`${branch}\` via [this commit](${REPO_URL}/commit/${generatedCommit}).`, }, codegen: { header: '### ✔️ Code generated!', diff --git a/scripts/ci/codegen/upsertGenerationComment.ts b/scripts/ci/codegen/upsertGenerationComment.ts index f2d6c84a7a..b9457566b7 100644 --- a/scripts/ci/codegen/upsertGenerationComment.ts +++ b/scripts/ci/codegen/upsertGenerationComment.ts @@ -19,10 +19,16 @@ const allowedTriggers = [ type Trigger = typeof allowedTriggers[number]; export async function getCommentBody(trigger: Trigger): Promise { - const generatedBranch = await run('git branch --show-current'); + let generatedBranch = await run('git branch --show-current'); + + // `cleanup` is triggered on PR close, which runs on `main`, so we lose the + // branch name context at this point + if (generatedBranch === 'main' && process.env.HEAD_BRANCH) { + generatedBranch = `generated/${process.env.HEAD_BRANCH}`; + } + const baseBranch = generatedBranch.replace('generated/', ''); const baseCommit = await run(`git show ${baseBranch} -s --format=%H`); - const generatedCommit = await run( `git show ${generatedBranch} -s --format=%H` );