Skip to content

Commit 4d4b962

Browse files
carlosdelestelasticsearchmachine
andauthored
Synonyms API - Add refresh parameter to check synonyms index and reload analyzers (#126935)
* Add timeout to SynonymsManagementAPIService put synonyms * Remove replicas 0, as that may impact serverless * Add timeout to put synonyms action, fix tests * Fix number of replicas * Remove cluster.health checks for synonyms index * Revert debugging * Add integration test for timeouts * Use TimeValue instead of an int * Add YAML tests and REST API specs * Fix a validation bug in put synonym rule * Spotless * Update docs/changelog/126314.yaml * Remove unnecessary checks for null * Fix equals / HashCode * Checks that timeout is passed correctly to the check health method * Use correctly the default timeout * spotless * Add monitor cluster privilege to internal synonyms user * [CI] Auto commit changes from spotless * Add capabilities to avoid failing on bwc tests * Replace timeout for refresh param * Add param to specs * Add YAML tests * Fix changelog * [CI] Auto commit changes from spotless * Use BWC serialization tests * Fix bug in test parser * Spotless * Delete doesn't need reloading 🤦 removing it * Revert "Delete doesn't need reloading 🤦 removing it" This reverts commit 9c8e0b6. * [CI] Auto commit changes from spotless * Fix refresh for delete synonym rule * Fix tests * Update docs/changelog/126935.yaml * Add reload analyzers test * reload_analyzers is not available on serverless --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent 2ea04a9 commit 4d4b962

35 files changed

+718
-190
lines changed

docs/changelog/126314.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126314
2+
summary: Add refresh to synonyms put / delete APIs to wait for synonyms to be accessible and reload analyzers
3+
area: Analysis
4+
type: bug
5+
issues:
6+
- 121441

docs/changelog/126935.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126935
2+
summary: Synonyms API - Add refresh parameter to check synonyms index and reload analyzers
3+
area: Analysis
4+
type: enhancement
5+
issues:
6+
- 121441

rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.delete_synonym_rule.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
}
3434
}
3535
]
36+
},
37+
"params": {
38+
"refresh": {
39+
"type": "boolean",
40+
"description": "Refresh search analyzers to update synonyms"
41+
}
3642
}
3743
}
3844
}

rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.put_synonym.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
}
3131
]
3232
},
33+
"params": {
34+
"refresh": {
35+
"type": "boolean",
36+
"description": "Refresh search analyzers to update synonyms"
37+
}
38+
},
3339
"body": {
3440
"description": "Synonyms set rules",
3541
"required": true

rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.put_synonym_rule.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
}
3535
]
3636
},
37+
"params": {
38+
"refresh": {
39+
"type": "boolean",
40+
"description": "Refresh search analyzers to update synonyms"
41+
}
42+
},
3743
"body": {
3844
"description": "Synonym rule",
3945
"required": true

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/10_synonyms_put.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ setup:
1515

1616
- match: { result: "created" }
1717

18-
- do:
19-
cluster.health:
20-
index: .synonyms
21-
wait_for_status: green
22-
2318
- do:
2419
synonyms.get_synonym:
2520
id: test-update-synonyms
@@ -63,18 +58,38 @@ setup:
6358

6459
- match: { result: "created" }
6560

66-
- do:
67-
cluster.health:
68-
index: .synonyms
69-
wait_for_status: green
70-
7161
- do:
7262
synonyms.get_synonym:
7363
id: test-empty-synonyms
7464

7565
- match: { count: 0 }
7666
- match: { synonyms_set: [] }
7767

68+
---
69+
"Refresh can be specified":
70+
71+
- requires:
72+
test_runner_features: [ capabilities ]
73+
capabilities:
74+
- method: PUT
75+
path: /_synonyms/{rule_id}
76+
capabilities: [ synonyms_refresh_param ]
77+
reason: "synonyms refresh param capability needed"
78+
79+
- do:
80+
synonyms.put_synonym:
81+
id: test-update-synonyms
82+
refresh: false
83+
body:
84+
synonyms_set:
85+
- synonyms: "hello, hi"
86+
- synonyms: "bye => goodbye"
87+
id: "test-id"
88+
89+
- match: { result: "created" }
90+
# Reload analyzers info is not included
91+
- not_exists: reload_analyzers_details
92+
7893
---
7994
"Validation fails tests":
8095
- do:
@@ -116,3 +131,4 @@ setup:
116131
body:
117132
synonyms_set:
118133
- synonyms: "bye, goodbye, "
134+

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/110_synonyms_invalid.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ setup:
1111
synonyms_set:
1212
synonyms: "foo => bar, baz"
1313

14-
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
15-
- do:
16-
cluster.health:
17-
index: .synonyms
18-
wait_for_status: green
19-
2014
- do:
2115
indices.create:
2216
index: test_index
@@ -372,13 +366,6 @@ setup:
372366
synonyms_set:
373367
synonyms: "foo => bar, baz"
374368

375-
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
376-
- do:
377-
cluster.health:
378-
index: .synonyms
379-
wait_for_status: green
380-
381-
382369
- do:
383370
indices.stats: { index: test_index }
384371

@@ -441,12 +428,6 @@ setup:
441428
synonyms_set:
442429
synonyms: "foo => bar, baz"
443430

444-
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
445-
- do:
446-
cluster.health:
447-
index: .synonyms
448-
wait_for_status: green
449-
450431
- do:
451432
# Warning issued in previous versions
452433
allowed_warnings:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/20_synonyms_get.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ setup:
1414
- synonyms: "test => check"
1515
id: "test-id-3"
1616

17-
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
18-
- do:
19-
cluster.health:
20-
index: .synonyms
21-
wait_for_status: green
22-
2317
---
2418
"Get synonyms set":
2519
- do:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/30_synonyms_delete.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ setup:
1212
- synonyms: "bye => goodbye"
1313
id: "test-id-2"
1414

15-
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
16-
- do:
17-
cluster.health:
18-
index: .synonyms
19-
wait_for_status: green
20-
2115
---
2216
"Delete synonyms set":
2317
- do:
@@ -77,7 +71,6 @@ setup:
7771
settings:
7872
index:
7973
number_of_shards: 1
80-
number_of_replicas: 0
8174
analysis:
8275
filter:
8376
my_synonym_filter:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/40_synonyms_sets_get.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ setup:
1010
- synonyms: "hello, hi"
1111
- synonyms: "goodbye, bye"
1212

13-
# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
14-
- do:
15-
cluster.health:
16-
index: .synonyms
17-
wait_for_status: green
18-
1913
- do:
2014
synonyms.put_synonym:
2115
id: test-synonyms-1

0 commit comments

Comments
 (0)