-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Non existing synonyms sets do not fail shard recovery #125659
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
Changes from 6 commits
a77c9a4
88abdff
41e66ce
ad8474f
5a0149e
1623a0e
636bea9
dd3db4d
ecb2f26
444ca17
7967259
bb6f970
b88fdc4
d78eff2
5f813b1
6ace60b
19955f2
cec345f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,34 +165,6 @@ setup: | |
| query: hola | ||
| - match: { hits.total.value: 1 } | ||
|
|
||
| --- | ||
| "Fail loading synonyms from index if synonyms_set doesn't exist": | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this test to 100_synonyms_invalid |
||
| - do: | ||
| indices.create: | ||
| index: another_index | ||
| body: | ||
| settings: | ||
| index: | ||
| number_of_shards: 1 | ||
| analysis: | ||
| filter: | ||
| my_synonym_filter: | ||
| type: synonym | ||
| synonyms_set: set_missing | ||
| updateable: true | ||
| analyzer: | ||
| my_analyzer: | ||
| type: custom | ||
| tokenizer: standard | ||
| filter: [ lowercase, my_synonym_filter ] | ||
| mappings: | ||
| properties: | ||
| my_field: | ||
| type: text | ||
| search_analyzer: my_analyzer | ||
| - match: { acknowledged: true } | ||
| - match: { shards_acknowledged: false } | ||
|
|
||
| --- | ||
| "Load empty synonyms set from index for an analyzer": | ||
| - do: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| import org.apache.lucene.analysis.th.ThaiAnalyzer; | ||
| import org.apache.lucene.analysis.tr.TurkishAnalyzer; | ||
| import org.apache.lucene.analysis.util.CSVUtil; | ||
| import org.elasticsearch.ResourceNotFoundException; | ||
| import org.elasticsearch.action.support.PlainActionFuture; | ||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.common.settings.Settings; | ||
|
|
@@ -353,10 +354,27 @@ public static Reader getReaderFromFile(Environment env, String filePath, String | |
| } | ||
| } | ||
|
|
||
| public static Reader getReaderFromIndex(String synonymsSet, SynonymsManagementAPIService synonymsManagementAPIService) { | ||
| public static Reader getReaderFromIndex( | ||
| String synonymsSet, | ||
| SynonymsManagementAPIService synonymsManagementAPIService, | ||
| boolean ignoreMissing | ||
| ) { | ||
| final PlainActionFuture<PagedResult<SynonymRule>> synonymsLoadingFuture = new PlainActionFuture<>(); | ||
| synonymsManagementAPIService.getSynonymSetRules(synonymsSet, synonymsLoadingFuture); | ||
| PagedResult<SynonymRule> results = synonymsLoadingFuture.actionGet(); | ||
|
|
||
| PagedResult<SynonymRule> results; | ||
| try { | ||
| results = synonymsLoadingFuture.actionGet(); | ||
| } catch (ResourceNotFoundException e) { | ||
| if (ignoreMissing == false) { | ||
| throw e; | ||
| } | ||
| logger.warn( | ||
|
||
| "Synonyms set {} not found - synonyms will not be applied to search results on indices that use this synonym set", | ||
| synonymsSet | ||
| ); | ||
| results = new PagedResult<>(0, new SynonymRule[0]); | ||
| } | ||
|
|
||
| SynonymRule[] synonymRules = results.pageResults(); | ||
| StringBuilder sb = new StringBuilder(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,14 @@ public class CreateIndexCapabilities { | |
|
|
||
| private static final String HUNSPELL_DICT_400 = "hunspell_dict_400"; | ||
|
|
||
| private static final String SYNONYMS_SET_LENIENT_ON_NON_EXISTING = "synonyms_set_lenient_on_non_existing"; | ||
|
|
||
| public static final Set<String> CAPABILITIES = Set.of( | ||
| LOGSDB_INDEX_MODE_CAPABILITY, | ||
| LOOKUP_INDEX_MODE_CAPABILITY, | ||
| NESTED_DENSE_VECTOR_SYNTHETIC_TEST, | ||
| POORLY_FORMATTED_BAD_REQUEST, | ||
| HUNSPELL_DICT_400 | ||
| HUNSPELL_DICT_400, | ||
| SYNONYMS_SET_LENIENT_ON_NON_EXISTING | ||
|
||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to this change, but a good opportunity to enable this test again