Skip to content

Commit 94a3330

Browse files
authored
Fix and tune synonyms API (#2235)
1 parent 82a3e5f commit 94a3330

19 files changed

+250
-344
lines changed

output/schema/schema.json

Lines changed: 155 additions & 198 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/validation-errors.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

Lines changed: 33 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/indices/reload_search_analyzers/ReloadSearchAnalyzersResponse.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
* under the License.
1818
*/
1919

20-
import { ShardStatistics } from '@_types/Stats'
21-
import { ReloadDetails } from './types'
20+
import { ReloadResult } from './types'
2221

2322
export class Response {
24-
body: { reload_details: ReloadDetails[]; _shards: ShardStatistics }
23+
body: ReloadResult
2524
}

specification/indices/reload_search_analyzers/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
* under the License.
1818
*/
1919

20+
import { ShardStatistics } from '@_types/Stats'
21+
22+
export class ReloadResult {
23+
reload_details: ReloadDetails[]
24+
_shards: ShardStatistics
25+
}
26+
2027
export class ReloadDetails {
2128
index: string
2229
reloaded_analyzers: string[]

specification/synonyms/_types/SynonymRule.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
*/
1919

2020
import { Id } from '@_types/common'
21+
import { OverloadOf } from '@spec_utils/behaviors'
2122

2223
export type SynonymString = string
2324

2425
// Synonym Rule with optional ID, used for PUT method
25-
export class SynonymRuleOptionalId {
26+
export class SynonymRule {
2627
/**
2728
* Synonym Rule identifier
2829
*/
@@ -34,9 +35,13 @@ export class SynonymRuleOptionalId {
3435
}
3536

3637
// Synonym Rule with mandatory ID, used for responses (which always include it)
37-
export class SynonymRule extends SynonymRuleOptionalId {
38+
export class SynonymRuleRead implements OverloadOf<SynonymRule> {
3839
/**
3940
* Synonym Rule identifier
4041
*/
4142
id: Id
43+
/**
44+
* Synonyms, in Solr format, that conform the synonym rule. See https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-graph-tokenfilter.html#_solr_synonyms_2
45+
*/
46+
synonyms: SynonymString
4247
}

specification/synonyms/_types/SynonymsSet.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

specification/synonyms/_types/SynonymsUpdateResult.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
*/
1919

2020
import { Result } from '@_types/Result'
21-
import { ReloadDetails } from '@indices/reload_search_analyzers/types'
22-
import { ShardStatistics } from '@_types/Stats'
21+
import { ReloadResult } from '@indices/reload_search_analyzers/types'
2322

2423
export class SynonymsUpdateResult {
2524
/**
@@ -31,6 +30,5 @@ export class SynonymsUpdateResult {
3130
* Updating synonyms in a synonym set reloads the associated analyzers.
3231
* This is the analyzers reloading result
3332
*/
34-
reload_analyzers_details: ReloadDetails[]
35-
_shards: ShardStatistics
33+
reload_analyzers_details: ReloadResult
3634
}

specification/synonyms/delete_synonym/SynonymsDeleteRequest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import { RequestBase } from '@_types/Base'
20-
import { Name } from '@_types/common'
20+
import { Id } from '@_types/common'
2121

2222
/**
2323
* Deletes a synonym set
@@ -30,6 +30,6 @@ interface Request extends RequestBase {
3030
/**
3131
* The id of the synonyms set to be deleted
3232
*/
33-
id: Name
33+
id: Id
3434
}
3535
}

specification/synonyms/delete_synonym_rule/SynonymRuleDeleteRequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import { RequestBase } from '@_types/Base'
20-
import { Name } from '@_types/common'
20+
import { Id } from '@_types/common'
2121

2222
/**
2323
* Deletes a synonym rule in a synonym set
@@ -30,11 +30,11 @@ interface Request extends RequestBase {
3030
/**
3131
* The id of the synonym set to be updated
3232
*/
33-
set_id: Name
33+
set_id: Id
3434

3535
/**
3636
* The id of the synonym rule to be deleted
3737
*/
38-
rule_id: Name
38+
rule_id: Id
3939
}
4040
}

specification/synonyms/get_synonym/SynonymsGetRequest.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
* under the License.
1818
*/
1919
import { RequestBase } from '@_types/Base'
20-
import { Name } from '@_types/common'
21-
import { SynonymsSet } from '../_types/SynonymsSet'
20+
import { Id } from '@_types/common'
2221
import { integer } from '@_types/Numeric'
2322

2423
/**
@@ -32,15 +31,17 @@ interface Request extends RequestBase {
3231
/**
3332
* "The id of the synonyms set to be retrieved
3433
*/
35-
id: Name
34+
id: Id
3635
}
3736
query_parameters: {
3837
/**
39-
* Starting offset for query rules to be retrieved (default: 0)
38+
* Starting offset for query rules to be retrieved
39+
* @server_default 0
4040
*/
4141
from?: integer
4242
/**
43-
* specifies a max number of query rules to retrieve (default: 10)
43+
* specifies a max number of query rules to retrieve
44+
* @server_default 10
4445
*/
4546
size?: integer
4647
}

specification/synonyms/get_synonym/SynonymsGetResponse.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
* under the License.
1818
*/
1919

20-
import { Result } from '@_types/Result'
21-
import { ReloadDetails } from '@indices/reload_search_analyzers/types'
22-
import { ShardStatistics } from '@_types/Stats'
2320
import { integer } from '@_types/Numeric'
24-
import { SynonymsSet } from '../_types/SynonymsSet'
21+
import { SynonymRuleRead } from '../_types/SynonymRule'
2522

2623
export class Response {
2724
body: {
2825
count: integer
29-
synonyms_set: SynonymsSet
26+
synonyms_set: SynonymRuleRead[]
3027
}
3128
}

specification/synonyms/get_synonym_rule/SynonymRuleGetRequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919
import { RequestBase } from '@_types/Base'
20-
import { Name } from '@_types/common'
20+
import { Id } from '@_types/common'
2121

2222
/**
2323
* Retrieves a synonym rule from a synonym set
@@ -30,11 +30,11 @@ interface Request extends RequestBase {
3030
/**
3131
* The id of the synonym set to retrieve the synonym rule from
3232
*/
33-
set_id: Name
33+
set_id: Id
3434

3535
/**
3636
* The id of the synonym rule to retrieve
3737
*/
38-
rule_id: Name
38+
rule_id: Id
3939
}
4040
}

0 commit comments

Comments
 (0)