From 1e847f4cafe3319153e9dda8d3391b6ec8371725 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 9 Jan 2025 17:00:00 +0100 Subject: [PATCH] fix(specs): move customRanking and keepDiacriticsOnCharacters to indexSettings [skip-bc] (#4324) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🧭 What and Why 🎟 JIRA Ticket: [DI-3373](https://algolia.atlassian.net/browse/DI-3373) fixes https://github.com/algolia/api-clients-automation/issues/4322 [DI-3373]: https://algolia.atlassian.net/browse/DI-3373?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- .../client/extensions/SearchForHits.kt | 2 - .../Search/Extra/SearchQueryExtension.swift | 4 - oxlintrc.json | 3 + scripts/ci/codegen/__tests__/codegen.test.ts | 1 + scripts/ci/codegen/pushToRepository.ts | 3 +- scripts/cts/testServer/index.ts | 4 +- .../release/__tests__/createReleasePR.test.ts | 4 + scripts/specs/__tests__/snippets.test.ts | 2 +- specs/common/schemas/IndexSettings.yml | 84 +++++++++---------- tests/CTS/requests/search/search.json | 8 -- 10 files changed, 55 insertions(+), 60 deletions(-) diff --git a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/extensions/SearchForHits.kt b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/extensions/SearchForHits.kt index bf981ef4b4..0d7ab801ca 100644 --- a/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/extensions/SearchForHits.kt +++ b/clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/extensions/SearchForHits.kt @@ -49,7 +49,6 @@ public fun SearchForHits.Companion.from( enableABTest = searchParamsObject.enableABTest, attributesToRetrieve = searchParamsObject.attributesToRetrieve, ranking = searchParamsObject.ranking, - customRanking = searchParamsObject.customRanking, relevancyStrictness = searchParamsObject.relevancyStrictness, attributesToHighlight = searchParamsObject.attributesToHighlight, attributesToSnippet = searchParamsObject.attributesToSnippet, @@ -65,7 +64,6 @@ public fun SearchForHits.Companion.from( disableTypoToleranceOnAttributes = searchParamsObject.disableTypoToleranceOnAttributes, ignorePlurals = searchParamsObject.ignorePlurals, removeStopWords = searchParamsObject.removeStopWords, - keepDiacriticsOnCharacters = searchParamsObject.keepDiacriticsOnCharacters, queryLanguages = searchParamsObject.queryLanguages, decompoundQuery = searchParamsObject.decompoundQuery, enableRules = searchParamsObject.enableRules, diff --git a/clients/algoliasearch-client-swift/Sources/Search/Extra/SearchQueryExtension.swift b/clients/algoliasearch-client-swift/Sources/Search/Extra/SearchQueryExtension.swift index cf5b94d158..9385fde14d 100644 --- a/clients/algoliasearch-client-swift/Sources/Search/Extra/SearchQueryExtension.swift +++ b/clients/algoliasearch-client-swift/Sources/Search/Extra/SearchQueryExtension.swift @@ -52,7 +52,6 @@ public extension SearchForHits { self.enableABTest = searchParamsObject.enableABTest self.attributesToRetrieve = searchParamsObject.attributesToRetrieve self.ranking = searchParamsObject.ranking - self.customRanking = searchParamsObject.customRanking self.relevancyStrictness = searchParamsObject.relevancyStrictness self.attributesToHighlight = searchParamsObject.attributesToHighlight self.attributesToSnippet = searchParamsObject.attributesToSnippet @@ -68,7 +67,6 @@ public extension SearchForHits { self.disableTypoToleranceOnAttributes = searchParamsObject.disableTypoToleranceOnAttributes self.ignorePlurals = searchParamsObject.ignorePlurals self.removeStopWords = searchParamsObject.removeStopWords - self.keepDiacriticsOnCharacters = searchParamsObject.keepDiacriticsOnCharacters self.queryLanguages = searchParamsObject.queryLanguages self.decompoundQuery = searchParamsObject.decompoundQuery self.enableRules = searchParamsObject.enableRules @@ -139,7 +137,6 @@ public extension SearchForFacets { self.enableABTest = searchParamsObject.enableABTest self.attributesToRetrieve = searchParamsObject.attributesToRetrieve self.ranking = searchParamsObject.ranking - self.customRanking = searchParamsObject.customRanking self.relevancyStrictness = searchParamsObject.relevancyStrictness self.attributesToHighlight = searchParamsObject.attributesToHighlight self.attributesToSnippet = searchParamsObject.attributesToSnippet @@ -155,7 +152,6 @@ public extension SearchForFacets { self.disableTypoToleranceOnAttributes = searchParamsObject.disableTypoToleranceOnAttributes self.ignorePlurals = searchParamsObject.ignorePlurals self.removeStopWords = searchParamsObject.removeStopWords - self.keepDiacriticsOnCharacters = searchParamsObject.keepDiacriticsOnCharacters self.queryLanguages = searchParamsObject.queryLanguages self.decompoundQuery = searchParamsObject.decompoundQuery self.enableRules = searchParamsObject.enableRules diff --git a/oxlintrc.json b/oxlintrc.json index 22abc7fb2b..f643803aed 100644 --- a/oxlintrc.json +++ b/oxlintrc.json @@ -1,5 +1,8 @@ { "env": { "es6": true + }, + "rules": { + "@typescript-eslint/consistent-type-imports": "error" } } diff --git a/scripts/ci/codegen/__tests__/codegen.test.ts b/scripts/ci/codegen/__tests__/codegen.test.ts index fa1a3987ba..9a11ff993f 100644 --- a/scripts/ci/codegen/__tests__/codegen.test.ts +++ b/scripts/ci/codegen/__tests__/codegen.test.ts @@ -3,6 +3,7 @@ import { describe, expect, it, vi } from 'vitest'; import { pushGeneratedCode } from '../pushGeneratedCode.ts'; vi.mock('../../../common.ts', async (importOriginal) => { + // eslint-disable-next-line const mod = await importOriginal(); return { ...mod, diff --git a/scripts/ci/codegen/pushToRepository.ts b/scripts/ci/codegen/pushToRepository.ts index b11c00c46a..291b426842 100644 --- a/scripts/ci/codegen/pushToRepository.ts +++ b/scripts/ci/codegen/pushToRepository.ts @@ -15,7 +15,8 @@ import { toAbsolutePath, } from '../../common.ts'; import { getNbGitDiff } from '../utils.ts'; -import { GuidesToPush, pushToRepositoryConfiguration, RepositoryConfiguration, SpecsToPush } from './types.ts'; +import type { GuidesToPush, RepositoryConfiguration, SpecsToPush } from './types.ts'; +import { pushToRepositoryConfiguration } from './types.ts'; import { getClientsConfigField } from '../../config.ts'; import { commitStartRelease } from './text.ts'; diff --git a/scripts/cts/testServer/index.ts b/scripts/cts/testServer/index.ts index bd195ba20e..26f81212dd 100644 --- a/scripts/cts/testServer/index.ts +++ b/scripts/cts/testServer/index.ts @@ -61,13 +61,13 @@ export async function setupServer(name: string, port: number, addRoutes: (app: E addRoutes(app); // 404 handler - app.use((req, res) => { + app.use((req, _) => { console.error(`[PORT ${port}] endpoint not implemented for`, req.method, req.url); expect.fail('endpoint not implemented'); }); // catch all error handler - app.use((err, _req, res, _) => { + app.use((err, _req, _res, _) => { console.error(err.message); expect.fail(err.message); }); diff --git a/scripts/release/__tests__/createReleasePR.test.ts b/scripts/release/__tests__/createReleasePR.test.ts index 798bf31ea0..c0da966aa3 100644 --- a/scripts/release/__tests__/createReleasePR.test.ts +++ b/scripts/release/__tests__/createReleasePR.test.ts @@ -30,6 +30,7 @@ const buildTestCommit = ( // Mock `getOctokit` to bypass the API call and credential requirements vi.mock('../../common.ts', async (importOriginal) => { + // eslint-disable-next-line const mod = await importOriginal(); return { ...mod, @@ -48,6 +49,7 @@ vi.mock('../../common.ts', async (importOriginal) => { }); vi.mock('../../ci/utils.ts', async (importOriginal) => { + // eslint-disable-next-line const mod = await importOriginal(); return { ...mod, @@ -56,6 +58,7 @@ vi.mock('../../ci/utils.ts', async (importOriginal) => { }); vi.mock('../common.ts', async (importOriginal) => { + // eslint-disable-next-line const mod = await importOriginal(); const getFileChangesMockFn = vi.fn(); @@ -68,6 +71,7 @@ vi.mock('../common.ts', async (importOriginal) => { }); vi.mock('../../config.ts', async (importOriginal) => { + // eslint-disable-next-line const mod = await importOriginal(); return { ...mod, diff --git a/scripts/specs/__tests__/snippets.test.ts b/scripts/specs/__tests__/snippets.test.ts index e9c22e9e08..289eb025c2 100644 --- a/scripts/specs/__tests__/snippets.test.ts +++ b/scripts/specs/__tests__/snippets.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { parseCodeSamples } from '../snippets.ts'; -import { CodeSamples } from '../types.ts'; +import type { CodeSamples } from '../types.ts'; describe('init', () => { it('parses a multi line import', () => { diff --git a/specs/common/schemas/IndexSettings.yml b/specs/common/schemas/IndexSettings.yml index 8e9b613e66..3d0946df9a 100644 --- a/specs/common/schemas/IndexSettings.yml +++ b/specs/common/schemas/IndexSettings.yml @@ -285,6 +285,48 @@ baseIndexSettings: type: string maxFacetHits: $ref: '#/maxFacetHits' + keepDiacriticsOnCharacters: + type: string + example: øé + description: | + Characters for which diacritics should be preserved. + + By default, Algolia removes diacritics from letters. + For example, `é` becomes `e`. If this causes issues in your search, + you can specify characters that should keep their diacritics. + default: '' + x-categories: + - Languages + customRanking: + type: array + items: + type: string + example: + - desc(popularity) + - asc(price) + description: | + Attributes to use as [custom ranking](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/). + Attribute names are case-sensitive. + + The custom ranking attributes decide which items are shown first if the other ranking criteria are equal. + + Records with missing values for your selected custom ranking attributes are always sorted last. + Boolean attributes are sorted based on their alphabetical order. + + **Modifiers** + + - `asc("ATTRIBUTE")`. + Sort the index by the values of an attribute, in ascending order. + + - `desc("ATTRIBUTE")`. + Sort the index by the values of an attribute, in descending order. + + If you use two or more custom ranking attributes, + [reduce the precision](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/how-to/controlling-custom-ranking-metrics-precision/) of your first attributes, + or the other attributes will never be applied. + default: [] + x-categories: + - Ranking indexSettingsAsSearchParams: type: object @@ -343,36 +385,6 @@ indexSettingsAsSearchParams: - custom x-categories: - Ranking - customRanking: - type: array - items: - type: string - example: - - desc(popularity) - - asc(price) - description: | - Attributes to use as [custom ranking](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/). - Attribute names are case-sensitive. - - The custom ranking attributes decide which items are shown first if the other ranking criteria are equal. - - Records with missing values for your selected custom ranking attributes are always sorted last. - Boolean attributes are sorted based on their alphabetical order. - - **Modifiers** - - - `asc("ATTRIBUTE")`. - Sort the index by the values of an attribute, in ascending order. - - - `desc("ATTRIBUTE")`. - Sort the index by the values of an attribute, in descending order. - - If you use two or more custom ranking attributes, - [reduce the precision](https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/how-to/controlling-custom-ranking-metrics-precision/) of your first attributes, - or the other attributes will never be applied. - default: [] - x-categories: - - Ranking relevancyStrictness: type: integer example: 90 @@ -497,18 +509,6 @@ indexSettingsAsSearchParams: $ref: '#/ignorePlurals' removeStopWords: $ref: '#/removeStopWords' - keepDiacriticsOnCharacters: - type: string - example: øé - description: | - Characters for which diacritics should be preserved. - - By default, Algolia removes diacritics from letters. - For example, `é` becomes `e`. If this causes issues in your search, - you can specify characters that should keep their diacritics. - default: '' - x-categories: - - Languages queryLanguages: type: array items: diff --git a/tests/CTS/requests/search/search.json b/tests/CTS/requests/search/search.json index 57a7c467b2..d449aa4546 100644 --- a/tests/CTS/requests/search/search.json +++ b/tests/CTS/requests/search/search.json @@ -824,9 +824,6 @@ "" ], "clickAnalytics": true, - "customRanking": [ - "" - ], "decompoundQuery": true, "disableExactOnAttributes": [ "" @@ -886,7 +883,6 @@ 2.0104 ] ], - "keepDiacriticsOnCharacters": "", "length": 1, "maxValuesPerFacet": 0, "minProximity": 1, @@ -999,9 +995,6 @@ "" ], "clickAnalytics": true, - "customRanking": [ - "" - ], "decompoundQuery": true, "disableExactOnAttributes": [ "" @@ -1061,7 +1054,6 @@ 2.0104 ] ], - "keepDiacriticsOnCharacters": "", "length": 1, "maxValuesPerFacet": 0, "minProximity": 1,