// Path: src/main/java/org/codelibs/fess/suggest/exception/SuggestSettingsException.java
// public class SuggestSettingsException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public SuggestSettingsException(final String msg) {
//         super(msg);
//     }
// 
//     public SuggestSettingsException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public SuggestSettingsException(final String msg, final Throwable cause) {
//         super(msg, cause);
//     }
// }
// 
// Path: src/main/java/org/codelibs/fess/suggest/exception/SuggesterException.java
// public class SuggesterException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public SuggesterException(final String msg) {
//         super(msg);
//     }
// 
//     public SuggesterException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public SuggesterException(final String msg, final Throwable cause) {
//         super(msg, cause);
//     }
// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.suggest.exception.SuggestSettingsException;
import org.codelibs.fess.suggest.exception.SuggesterException;
import org.opensearch.action.get.GetResponse;
import org.opensearch.client.Client;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.index.IndexNotFoundException;
            value = defaultValue;
        } else {
            value = Float.parseFloat(obj.toString());
        }

        return value;
    }

    public boolean getAsBoolean(final String key, final boolean defaultValue) {
        final Object obj = get(key);

        final boolean value;
        if (obj == null) {
            value = defaultValue;
        } else {
            value = Boolean.parseBoolean(obj.toString());
        }

        return value;
    }

    public void set(final String key, final Object value) {
        if (logger.isLoggable(Level.FINER)) {
            logger.finer(() -> String.format("Set suggest settings. %s key: %s value: %s", settingsIndexName, key, value));
        }
        try {
            client.prepareUpdate().setIndex(settingsIndexName).setId(settingsId).setDocAsUpsert(true).setDoc(key, value)
                    .setRetryOnConflict(5).execute().actionGet(getIndexTimeout());
            client.admin().indices().prepareRefresh().setIndices(settingsIndexName).execute().actionGet(getIndicesTimeout());
        } catch (final Exception e) {
// Path: src/main/java/org/codelibs/fess/suggest/exception/SuggestSettingsException.java
// public class SuggestSettingsException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public SuggestSettingsException(final String msg) {
//         super(msg);
//     }
// 
//     public SuggestSettingsException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public SuggestSettingsException(final String msg, final Throwable cause) {
//         super(msg, cause);
//     }
// }
// 
// Path: src/main/java/org/codelibs/fess/suggest/exception/SuggesterException.java
// public class SuggesterException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public SuggesterException(final String msg) {
//         super(msg);
//     }
// 
//     public SuggesterException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public SuggesterException(final String msg, final Throwable cause) {
//         super(msg, cause);
//     }
// }


// Path: src/main/java/org/codelibs/fess/suggest/settings/SuggestSettings.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.fess.suggest.exception.SuggestSettingsException;
import org.codelibs.fess.suggest.exception.SuggesterException;
import org.opensearch.action.get.GetResponse;
import org.opensearch.client.Client;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.index.IndexNotFoundException;

            value = defaultValue;
        } else {
            value = Float.parseFloat(obj.toString());
        }

        return value;
    }

    public boolean getAsBoolean(final String key, final boolean defaultValue) {
        final Object obj = get(key);

        final boolean value;
        if (obj == null) {
            value = defaultValue;
        } else {
            value = Boolean.parseBoolean(obj.toString());
        }

        return value;
    }

    public void set(final String key, final Object value) {
        if (logger.isLoggable(Level.FINER)) {
            logger.finer(() -> String.format("Set suggest settings. %s key: %s value: %s", settingsIndexName, key, value));
        }
        try {
            client.prepareUpdate().setIndex(settingsIndexName).setId(settingsId).setDocAsUpsert(true).setDoc(key, value)
                    .setRetryOnConflict(5).execute().actionGet(getIndexTimeout());
            client.admin().indices().prepareRefresh().setIndices(settingsIndexName).execute().actionGet(getIndicesTimeout());
        } catch (final Exception e) {
            throw new SuggestSettingsException("Failed to update suggestSettings.", e);