Skip to content

Synonyms API - Add refresh parameter to check synonyms index and reload analyzers #126935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
dafbf90
Add timeout to SynonymsManagementAPIService put synonyms
carlosdelest Apr 4, 2025
a5a8a75
Remove replicas 0, as that may impact serverless
carlosdelest Apr 4, 2025
6e57ae3
Add timeout to put synonyms action, fix tests
carlosdelest Apr 4, 2025
7dee4b5
Fix number of replicas
carlosdelest Apr 4, 2025
19b5c33
Remove cluster.health checks for synonyms index
carlosdelest Apr 4, 2025
fcf4dc6
Revert debugging
carlosdelest Apr 4, 2025
51f67eb
Add integration test for timeouts
carlosdelest Apr 4, 2025
ab0805d
Use TimeValue instead of an int
carlosdelest Apr 4, 2025
3b8bbfd
Add YAML tests and REST API specs
carlosdelest Apr 4, 2025
8da7611
Fix a validation bug in put synonym rule
carlosdelest Apr 4, 2025
4ab01af
Spotless
carlosdelest Apr 4, 2025
6245d57
Update docs/changelog/126314.yaml
carlosdelest Apr 4, 2025
baca84c
Remove unnecessary checks for null
carlosdelest Apr 4, 2025
fbe393f
Fix equals / HashCode
carlosdelest Apr 4, 2025
a3dca50
Checks that timeout is passed correctly to the check health method
carlosdelest Apr 4, 2025
1ecfb12
Use correctly the default timeout
carlosdelest Apr 4, 2025
b419e4c
spotless
carlosdelest Apr 4, 2025
eaeaaf7
Add monitor cluster privilege to internal synonyms user
carlosdelest Apr 4, 2025
8fef96c
[CI] Auto commit changes from spotless
elasticsearchmachine Apr 4, 2025
8d3e221
Add capabilities to avoid failing on bwc tests
carlosdelest Apr 4, 2025
0044e80
Merge remote-tracking branch 'carlosdelest/bugfix/synonyms-index-sear…
carlosdelest Apr 4, 2025
535a426
Replace timeout for refresh param
carlosdelest Apr 16, 2025
f36056f
Add param to specs
carlosdelest Apr 16, 2025
5a8209a
Add YAML tests
carlosdelest Apr 16, 2025
e7eafda
Merge remote-tracking branch 'origin/main' into bugfix/synonyms-index…
carlosdelest Apr 16, 2025
d2b9544
Fix changelog
carlosdelest Apr 16, 2025
f8ee27a
[CI] Auto commit changes from spotless
elasticsearchmachine Apr 16, 2025
c6bcdbd
Use BWC serialization tests
carlosdelest Apr 16, 2025
0e3f6e7
Fix bug in test parser
carlosdelest Apr 16, 2025
47f8c6e
Spotless
carlosdelest Apr 16, 2025
9c8e0b6
Delete doesn't need reloading :facepalm: removing it
carlosdelest Apr 16, 2025
ea07420
Merge remote-tracking branch 'carlosdelest/bugfix/synonyms-index-sear…
carlosdelest Apr 16, 2025
1792888
Revert "Delete doesn't need reloading :facepalm: removing it"
carlosdelest Apr 16, 2025
9b77cbf
[CI] Auto commit changes from spotless
elasticsearchmachine Apr 16, 2025
098928c
Fix refresh for delete synonym rule
carlosdelest Apr 16, 2025
7743835
Merge remote-tracking branch 'carlosdelest/bugfix/synonyms-index-sear…
carlosdelest Apr 16, 2025
7a42657
Fix tests
carlosdelest Apr 16, 2025
a009193
Update docs/changelog/126935.yaml
carlosdelest Apr 17, 2025
2ad49d4
Merge remote-tracking branch 'origin/main' into bugfix/synonyms-index…
carlosdelest Apr 21, 2025
8c0dca5
Add reload analyzers test
carlosdelest Apr 21, 2025
fcf5f5a
reload_analyzers is not available on serverless
carlosdelest Apr 22, 2025
7451ea2
Merge remote-tracking branch 'origin/main' into bugfix/synonyms-index…
carlosdelest Apr 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/126314.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 126314
summary: Add refresh to synonyms put / delete APIs to wait for synonyms to be accessible and reload analyzers
area: Analysis
type: bug
issues:
- 121441
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
}
}
]
},
"params": {
"refresh": {
"type": "boolean",
"description": "Refresh search analyzers to update synonyms"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
}
]
},
"params": {
"refresh": {
"type": "boolean",
"description": "Refresh search analyzers to update synonyms"
}
},
"body": {
"description": "Synonyms set rules",
"required": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
}
]
},
"params": {
"refresh": {
"type": "boolean",
"description": "Refresh search analyzers to update synonyms"
}
},
"body": {
"description": "Synonym rule",
"required": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ setup:

- match: { result: "created" }

- do:
cluster.health:
index: .synonyms
wait_for_status: green

- do:
synonyms.get_synonym:
id: test-update-synonyms
Expand Down Expand Up @@ -63,18 +58,38 @@ setup:

- match: { result: "created" }

- do:
cluster.health:
index: .synonyms
wait_for_status: green

- do:
synonyms.get_synonym:
id: test-empty-synonyms

- match: { count: 0 }
- match: { synonyms_set: [] }

---
"Refresh can be specified":

- requires:
test_runner_features: [ capabilities ]
capabilities:
- method: PUT
path: /_synonyms/{rule_id}
capabilities: [ synonyms_refresh_param ]
reason: "synonyms refresh param capability needed"

- do:
synonyms.put_synonym:
id: test-update-synonyms
refresh: false
body:
synonyms_set:
- synonyms: "hello, hi"
- synonyms: "bye => goodbye"
id: "test-id"

- match: { result: "created" }
# Reload analyzers info is not included
- not_exists: reload_analyzers_details

---
"Validation fails tests":
- do:
Expand Down Expand Up @@ -116,3 +131,4 @@ setup:
body:
synonyms_set:
- synonyms: "bye, goodbye, "

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ setup:
synonyms_set:
synonyms: "foo => bar, baz"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

- do:
indices.create:
index: test_index
Expand Down Expand Up @@ -372,13 +366,6 @@ setup:
synonyms_set:
synonyms: "foo => bar, baz"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green


- do:
indices.stats: { index: test_index }

Expand Down Expand Up @@ -441,12 +428,6 @@ setup:
synonyms_set:
synonyms: "foo => bar, baz"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

- do:
# Warning issued in previous versions
allowed_warnings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ setup:
- synonyms: "test => check"
id: "test-id-3"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

---
"Get synonyms set":
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ setup:
- synonyms: "bye => goodbye"
id: "test-id-2"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

---
"Delete synonyms set":
- do:
Expand Down Expand Up @@ -77,7 +71,6 @@ setup:
settings:
index:
number_of_shards: 1
number_of_replicas: 0
analysis:
filter:
my_synonym_filter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ setup:
- synonyms: "hello, hi"
- synonyms: "goodbye, bye"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

- do:
synonyms.put_synonym:
id: test-synonyms-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ setup:
- synonyms: "test => check"
id: "test-id-3"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

---
"Update a synonyms rule":
- do:
Expand Down Expand Up @@ -85,3 +79,68 @@ setup:
rule_id: "test-id-0"
body:
synonyms: "i-phone, iphone"

---
"Refresh can be specified":

- requires:
test_runner_features: [ capabilities ]
capabilities:
- method: PUT
path: /_synonyms/{rule_id}
capabilities: [ synonyms_refresh_param ]
reason: "synonyms refresh param capability needed"

- do:
synonyms.put_synonym_rule:
refresh: false
set_id: "test-synonyms"
rule_id: "test-id-2"
body:
synonyms: "bye, goodbye, seeya"

- match: { result: "updated" }
# Reload analyzers info is not included
- not_exists: reload_analyzers_details

---
"Validation failure tests":
- do:
catch: /\[synonyms\] field can't be empty/
synonyms.put_synonym_rule:
set_id: "test-synonyms"
rule_id: "test-id-0"
body:
synonyms: ""

- do:
catch: /More than one explicit mapping specified in the same synonyms rule/
synonyms.put_synonym_rule:
set_id: "test-synonyms"
rule_id: "test-id-0"
body:
synonyms: "bye => => goodbye"

- do:
catch: /Incorrect syntax for \[synonyms\]/
synonyms.put_synonym_rule:
set_id: "test-synonyms"
rule_id: "test-id-0"
body:
synonyms: " => goodbye"

- do:
catch: /Incorrect syntax for \[synonyms\]/
synonyms.put_synonym_rule:
set_id: "test-synonyms"
rule_id: "test-id-0"
body:
synonyms: "bye => "

- do:
catch: /Incorrect syntax for \[synonyms\]/
synonyms.put_synonym_rule:
set_id: "test-synonyms"
rule_id: "test-id-0"
body:
synonyms: "bye, goodbye, "
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ setup:
- synonyms: "test => check"
id: "test-id-3"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

---
"Get a synonym rule":
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ setup:
- synonyms: "test => check"
id: "test-id-3"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

---
"Delete synonym rule":
- do:
Expand Down Expand Up @@ -50,6 +44,27 @@ setup:
- synonyms: "test => check"
id: "test-id-3"

---
"Refresh can be specified":

- requires:
test_runner_features: [ capabilities ]
capabilities:
- method: PUT
path: /_synonyms/{rule_id}
capabilities: [ synonyms_refresh_param ]
reason: "synonyms refresh param capability needed"

- do:
synonyms.delete_synonym_rule:
set_id: test-synonyms
rule_id: test-id-2
refresh: false

- match: { result: "deleted" }
# Reload analyzers info is not included
- not_exists: reload_analyzers_details

---
"Delete synonym rule - missing synonym set":
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ setup:
- synonyms: "bye => goodbye"
id: "synonym-rule-2"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

# Create an index with synonym_filter that uses that synonyms set
- do:
indices.create:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ setup:
- synonyms: "bye => goodbye"
id: "synonym-rule-2"

# This is to ensure that all index shards (write and read) are available. In serverless this can take some time.
- do:
cluster.health:
index: .synonyms
wait_for_status: green

# Create synonyms synonyms_set2
- do:
synonyms.put_synonym:
Expand Down
Loading
Loading