From 85caa4f6e3b00e2bb190934a4301f599c24202ba Mon Sep 17 00:00:00 2001 From: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:00:02 +0900 Subject: [PATCH] Use INDEX mode if an invalid value is set for mode in the kuromoji_completion filter Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> --- .../analysis/KuromojiCompletionFilterFactory.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/analysis-kuromoji/src/main/java/org/opensearch/index/analysis/KuromojiCompletionFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/opensearch/index/analysis/KuromojiCompletionFilterFactory.java index 3c6a1132b1e9b..1459c19de46db 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/opensearch/index/analysis/KuromojiCompletionFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/opensearch/index/analysis/KuromojiCompletionFilterFactory.java @@ -25,11 +25,14 @@ public KuromojiCompletionFilterFactory(IndexSettings indexSettings, Environment public static Mode getMode(Settings settings) { String modeSetting = settings.get("mode", null); - if (modeSetting == null || "index".equalsIgnoreCase(modeSetting)) { - return Mode.INDEX; - } else { - return Mode.QUERY; + if (modeSetting != null) { + if ("index".equalsIgnoreCase(modeSetting)) { + return Mode.INDEX; + } else if ("query".equalsIgnoreCase(modeSetting)) { + return Mode.QUERY; + } } + return Mode.INDEX; } @Override