Skip to content

Commit c918a50

Browse files
committed
Adjust exception thrown when unable to load hunspell dict
1 parent e05304b commit c918a50

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/10_basic.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,30 @@
273273

274274
- match: { error.type: "mapper_parsing_exception" }
275275
- match: { error.reason: "Failed to parse mapping: The mapper type [invalid] declared on field [raw] does not exist. It might have been created within a future version or requires a plugin to be installed. Check the documentation." }
276+
---
277+
"Create index with hunspell missing dict":
278+
- requires:
279+
test_runner_features: [ capabilities ]
280+
capabilities:
281+
- method: PUT
282+
path: /{index}
283+
capabilities: [ hunspell_dict_400 ]
284+
reason: "bugfix 'hunspell_dict_400' capability required"
285+
286+
- do:
287+
catch: bad_request
288+
indices.create:
289+
index: bad_hunspell_index
290+
body:
291+
settings:
292+
analysis:
293+
analyzer:
294+
en:
295+
tokenizer: standard
296+
filter:
297+
- my_en_US_dict_stemmer
298+
filter:
299+
my_en_US_dict_stemmer:
300+
type: hunspell
301+
locale: en_US
302+
dedup: false

server/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public HunspellService(final Settings settings, final Environment env, final Map
9999
try {
100100
return loadDictionary(locale, settings, env);
101101
} catch (Exception e) {
102-
throw new IllegalStateException("failed to load hunspell dictionary for locale: " + locale, e);
102+
throw new IllegalArgumentException("failed to load hunspell dictionary for locale: " + locale, e);
103103
}
104104
};
105105
if (HUNSPELL_LAZY_LOAD.get(settings) == false) {

server/src/main/java/org/elasticsearch/rest/action/admin/indices/CreateIndexCapabilities.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ public class CreateIndexCapabilities {
2828

2929
private static final String NESTED_DENSE_VECTOR_SYNTHETIC_TEST = "nested_dense_vector_synthetic_test";
3030

31+
private static final String HUNSPELL_DICT_400 = "hunspell_dict_400";
32+
3133
public static final Set<String> CAPABILITIES = Set.of(
3234
LOGSDB_INDEX_MODE_CAPABILITY,
3335
LOOKUP_INDEX_MODE_CAPABILITY,
34-
NESTED_DENSE_VECTOR_SYNTHETIC_TEST
36+
NESTED_DENSE_VECTOR_SYNTHETIC_TEST,
37+
HUNSPELL_DICT_400
3538
);
3639
}

0 commit comments

Comments
 (0)