Skip to content

Commit 7dc719c

Browse files
authored
fix(specs): make languages an enum (#2865)
1 parent abe1e8b commit 7dc719c

File tree

8 files changed

+100
-36
lines changed

8 files changed

+100
-36
lines changed

specs/common/schemas/IndexSettings.yml

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ baseIndexSettings:
132132
type: array
133133
items:
134134
type: string
135-
example: ['description']
135+
example: [description]
136136
description: Attributes for which to split [camel case](https://wikipedia.org/wiki/Camel_case) words.
137137
default: []
138138
x-categories:
@@ -158,11 +158,11 @@ baseIndexSettings:
158158
indexLanguages:
159159
type: array
160160
items:
161-
type: string
161+
$ref: '#/supportedLanguage'
162162
example:
163163
- ja
164164
description: |
165-
[ISO code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) for a language for language-specific processing steps, such as word detection and dictionary settings.
165+
Languages for language-specific processing steps, such as word detection and dictionary settings.
166166
167167
**You should always specify an indexing language.**
168168
If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/),
@@ -519,17 +519,16 @@ indexSettingsAsSearchParams:
519519
queryLanguages:
520520
type: array
521521
items:
522-
type: string
522+
$ref: '#/supportedLanguage'
523523
example:
524524
- es
525525
description: |
526-
[ISO code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) for language-specific settings such as plurals, stop words, and word-detection dictionaries.
526+
Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries.
527527
528528
This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings.
529529
This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages.
530530
To support this, you must place the CJK language **first**.
531531
532-
533532
**You should always specify a query language.**
534533
If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/),
535534
or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters.
@@ -979,14 +978,14 @@ ignorePlurals:
979978
description: |
980979
Treat singular, plurals, and other forms of declensions as equivalent.
981980
You should only use this feature for the languages used in your index.
982-
example: ['ca', 'es']
981+
example: [ca, es]
983982
oneOf:
984983
- type: array
984+
description: |
985+
ISO code for languages for which this feature should be active.
986+
This overrides languages you set with `queryLanguages`.
985987
items:
986-
type: string
987-
description: |
988-
ISO code for languages for which this feature should be active.
989-
This overrides languages you set with `queryLanguages`.
988+
$ref: '#/supportedLanguage'
990989
- type: boolean
991990
description: |
992991
If true, `ignorePlurals` is active for all languages included in `queryLanguages`, or for all supported languages, if `queryLanguges` is empty.
@@ -1003,12 +1002,12 @@ removeStopWords:
10031002
In English, "the", "a", or "and" are stop words.
10041003
10051004
You should only use this feature for the languages used in your index.
1006-
example: ['ca', 'es']
1005+
example: [ca, es]
10071006
oneOf:
10081007
- type: array
1008+
description: ISO code for languages for which stop words should be removed. This overrides languages you set in `queryLanguges`.
10091009
items:
1010-
type: string
1011-
description: ISO code for languages for which stop words should be removed. This overrides languages you set in `queryLanguges`.
1010+
$ref: '#/supportedLanguage'
10121011
- type: boolean
10131012
default: false
10141013
description: |
@@ -1107,3 +1106,76 @@ semanticSearch:
11071106
type: array
11081107
items:
11091108
type: string
1109+
1110+
supportedLanguage:
1111+
type: string
1112+
description: ISO code for a supported language.
1113+
enum:
1114+
- af
1115+
- ar
1116+
- az
1117+
- bg
1118+
- bn
1119+
- ca
1120+
- cs
1121+
- cy
1122+
- da
1123+
- de
1124+
- el
1125+
- en
1126+
- eo
1127+
- es
1128+
- et
1129+
- eu
1130+
- fa
1131+
- fi
1132+
- fo
1133+
- fr
1134+
- ga
1135+
- gl
1136+
- he
1137+
- hi
1138+
- hu
1139+
- hy
1140+
- id
1141+
- is
1142+
- it
1143+
- ja
1144+
- ka
1145+
- kk
1146+
- ko
1147+
- ku
1148+
- ky
1149+
- lt
1150+
- lv
1151+
- mi
1152+
- mn
1153+
- mr
1154+
- ms
1155+
- mt
1156+
- nb
1157+
- nl
1158+
- no
1159+
- ns
1160+
- pl
1161+
- ps
1162+
- pt
1163+
- 'pt-br'
1164+
- qu
1165+
- ro
1166+
- ru
1167+
- sk
1168+
- sq
1169+
- sv
1170+
- sw
1171+
- ta
1172+
- te
1173+
- th
1174+
- tl
1175+
- tn
1176+
- tr
1177+
- tt
1178+
- uk
1179+
- ur
1180+
- uz
1181+
- zh

specs/search/paths/dictionaries/common/parameters.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ dictionaryType:
1111
type: string
1212
enum: [plurals, stopwords, compounds]
1313

14-
# misc
15-
language:
16-
description: ISO code of a [supported language](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/).
17-
example: en
18-
type: string
19-
2014
standardEntries:
2115
description: |
2216
Key-value pairs of [supported language ISO codes](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/) and boolean values.

specs/search/paths/dictionaries/common/schemas/SearchDictionaryEntriesResponse.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ dictionaryEntry:
3232
description: Unique identifier for the dictionary entry.
3333
example: 828afd405e1f4fe950b6b98c2c43c032
3434
language:
35-
type: string
36-
description: ISO code of a [supported language](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/).
37-
example: de
35+
$ref: '../../../../../common/schemas/IndexSettings.yml#/supportedLanguage'
3836
word:
3937
type: string
4038
description: Matching dictionary word for `stopwords` and `compounds` dictionaries.

specs/search/paths/dictionaries/searchDictionaryEntries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ post:
2929
hitsPerPage:
3030
$ref: '../../../common/schemas/IndexSettings.yml#/hitsPerPage'
3131
language:
32-
$ref: 'common/parameters.yml#/language'
32+
$ref: '../../../common/schemas/IndexSettings.yml#/supportedLanguage'
3333
responses:
3434
'200':
3535
description: OK

templates/kotlin/oneof_interface.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal class {{classname}}Serializer : JsonContentPolymorphicSerializer<{{clas
7373
element is JsonObject -> {{classname}}.{{#lambda.type-to-name}}{{{datatypeWithEnum}}}{{/lambda.type-to-name}}Value.serializer()
7474
{{/isMap}}
7575
{{#isArray}}
76-
element{{#items}}{{#isModel}}.isJsonArrayOfObjects{{/isModel}}{{#isPrimitiveType}}.isJsonArrayOfPrimitives{{/isPrimitiveType}}{{#isModel}}{{#isPrimitiveType}} is JsonArray{{/isPrimitiveType}}{{/isModel}}{{/items}} -> {{{classname}}}.{{#lambda.type-to-name}}{{{datatypeWithEnum}}}{{/lambda.type-to-name}}Value.serializer()
76+
element{{#items}}{{#isModel}}.isJsonArrayOfObjects{{/isModel}}{{#isPrimitiveType}}.isJsonArrayOfPrimitives{{/isPrimitiveType}}{{^isModel}}{{^isPrimitiveType}} is JsonArray{{/isPrimitiveType}}{{/isModel}}{{/items}} -> {{{classname}}}.{{#lambda.type-to-name}}{{{datatypeWithEnum}}}{{/lambda.type-to-name}}Value.serializer()
7777
{{/isArray}}
7878
{{#isEnumRef}}
7979
element.isString -> {{{datatypeWithEnum}}}.serializer()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#isObject}}{{objectName}}({{^hasAdditionalProperties}}{{#value}}{{> tests/generateParams}}{{^-last}}, {{/-last}}{{/value}}{{/hasAdditionalProperties}}{{#hasAdditionalProperties}}from: [{{#value}}"{{key}}": {{> tests/paramValue }}{{^-last}}, {{/-last}}{{/value}}]{{/hasAdditionalProperties}}){{/isObject}}{{#isString}}{{#isAnyType}}AnyCodable({{/isAnyType}}"{{{value}}}"{{#isAnyType}}){{/isAnyType}}{{/isString}}{{#isNumber}}{{#isLong}}Int64({{/isLong}}{{{value}}}{{#isLong}}){{/isLong}}{{/isNumber}}{{#isBoolean}}{{{value}}}{{/isBoolean}}{{#isEnum}}{{objectName}}.{{#lambda.swiftIdentifier}}{{#lambda.camelcase}}{{valueEscaped}}{{/lambda.camelcase}}{{/lambda.swiftIdentifier}}{{/isEnum}}{{#isArray}}[{{#value}}{{> tests/generateParams}}{{^-last}}, {{/-last}}{{/value}}]{{/isArray}}{{#isMap}}Map[{{{.}}}]{{/isMap}}{{#isFreeFormObject}}{{#isAnyType}}[{{#value}}{{#entrySet}}"{{key}}": "{{{value}}}"{{/entrySet}}{{/value}}]{{/isAnyType}}{{^isAnyType}}[{{^value}}:{{/value}}{{#value}}{{> tests/generateParams}}{{^-last}}, {{/-last}}{{/value}}]{{/isAnyType}}{{/isFreeFormObject}}{{#isNull}}{{#inClientTest}}TestNull{{{objectName}}}(){{/inClientTest}}{{/isNull}}
1+
{{#isObject}}{{objectName}}({{^hasAdditionalProperties}}{{#value}}{{> tests/generateParams}}{{^-last}}, {{/-last}}{{/value}}{{/hasAdditionalProperties}}{{#hasAdditionalProperties}}from: [{{#value}}"{{key}}": AnyCodable({{> tests/paramValue }}){{^-last}}, {{/-last}}{{/value}}]{{/hasAdditionalProperties}}){{/isObject}}{{#isString}}{{#isAnyType}}AnyCodable({{/isAnyType}}"{{{value}}}"{{#isAnyType}}){{/isAnyType}}{{/isString}}{{#isNumber}}{{#isLong}}Int64({{/isLong}}{{{value}}}{{#isLong}}){{/isLong}}{{/isNumber}}{{#isBoolean}}{{{value}}}{{/isBoolean}}{{#isEnum}}{{objectName}}.{{#lambda.swiftIdentifier}}{{#lambda.camelcase}}{{valueEscaped}}{{/lambda.camelcase}}{{/lambda.swiftIdentifier}}{{/isEnum}}{{#isArray}}[{{#value}}{{> tests/generateParams}}{{^-last}}, {{/-last}}{{/value}}]{{/isArray}}{{#isMap}}Map[{{{.}}}]{{/isMap}}{{#isFreeFormObject}}{{#isAnyType}}[{{#value}}{{#entrySet}}"{{key}}": "{{{value}}}"{{/entrySet}}{{/value}}]{{/isAnyType}}{{^isAnyType}}[{{^value}}:{{/value}}{{#value}}{{> tests/generateParams}}{{^-last}}, {{/-last}}{{/value}}]{{/isAnyType}}{{/isFreeFormObject}}{{#isNull}}{{#inClientTest}}TestNull{{{objectName}}}(){{/inClientTest}}{{/isNull}}

tests/CTS/requests/search/search.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@
460460
"personalizationImpact": 0,
461461
"query": "",
462462
"queryLanguages": [
463-
""
463+
"fr"
464464
],
465465
"queryType": "prefixAll",
466466
"ranking": [
@@ -635,7 +635,7 @@
635635
"personalizationImpact": 0,
636636
"query": "",
637637
"queryLanguages": [
638-
""
638+
"fr"
639639
],
640640
"queryType": "prefixAll",
641641
"ranking": [

tests/CTS/requests/search/setSettings.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"indexName": "theIndexName",
8989
"indexSettings": {
9090
"ignorePlurals": [
91-
"algolia"
91+
"fr"
9292
]
9393
},
9494
"forwardToReplicas": true
@@ -98,7 +98,7 @@
9898
"method": "PUT",
9999
"body": {
100100
"ignorePlurals": [
101-
"algolia"
101+
"fr"
102102
]
103103
},
104104
"queryParameters": {
@@ -132,7 +132,7 @@
132132
"indexName": "theIndexName",
133133
"indexSettings": {
134134
"removeStopWords": [
135-
"algolia"
135+
"fr"
136136
]
137137
},
138138
"forwardToReplicas": true
@@ -142,7 +142,7 @@
142142
"method": "PUT",
143143
"body": {
144144
"removeStopWords": [
145-
"algolia"
145+
"fr"
146146
]
147147
},
148148
"queryParameters": {
@@ -258,7 +258,7 @@
258258
"hitsPerPage": 10,
259259
"ignorePlurals": false,
260260
"indexLanguages": [
261-
"algolia"
261+
"fr"
262262
],
263263
"keepDiacriticsOnCharacters": "abc",
264264
"maxFacetHits": 20,
@@ -275,7 +275,7 @@
275275
],
276276
"paginationLimitedTo": 0,
277277
"queryLanguages": [
278-
"algolia"
278+
"fr"
279279
],
280280
"queryType": "prefixLast",
281281
"ranking": [
@@ -398,7 +398,7 @@
398398
"hitsPerPage": 10,
399399
"ignorePlurals": false,
400400
"indexLanguages": [
401-
"algolia"
401+
"fr"
402402
],
403403
"keepDiacriticsOnCharacters": "abc",
404404
"maxFacetHits": 20,
@@ -415,7 +415,7 @@
415415
],
416416
"paginationLimitedTo": 0,
417417
"queryLanguages": [
418-
"algolia"
418+
"fr"
419419
],
420420
"queryType": "prefixLast",
421421
"ranking": [

0 commit comments

Comments
 (0)