org.elasticsearch.common.settings.Settings.getAsSettings()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.elasticsearch.common.settings.Settings.getAsSettings()方法的一些代码示例,展示了Settings.getAsSettings()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getAsSettings()方法的具体详情如下:
包路径:org.elasticsearch.common.settings.Settings
类名称:Settings
方法名:getAsSettings

Settings.getAsSettings介绍

[英]Returns the settings mapped to the given setting name.
[中]返回映射到给定设置名称的设置。

代码示例

代码示例来源:origin: floragunncom/search-guard

authorizationBackend = newInstance(
    authzBackendClazz,"z",
    Settings.builder().put(esSettings).put(ads.getAsSettings("authorization_backend.config")).build(), configPath);
authenticationBackend = newInstance(
    authBackendClazz,"c",
    Settings.builder().put(esSettings).put(ads.getAsSettings("authentication_backend.config")).build(), configPath);
  Settings.builder().put(esSettings).put(ads.getAsSettings("http_authenticator.config")).build(), configPath);

代码示例来源:origin: floragunncom/search-guard

if (OpenBSDBCrypt.checkPassword(hashed, array)) {
  final List<String> roles = cfg.getAsList(credentials.getUsername() + ".roles", Collections.emptyList());
  final Settings customAttributes = cfg.getAsSettings(credentials.getUsername() + ".attributes");

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Returns a {@link Settings} by groupName from {@link IndexSettings} or a default {@link Settings}
 * @param indexSettings an index settings
 * @param groupName tokenizer/token filter/char filter name
 * @return {@link Settings}
 */
public static Settings getSettingsFromIndexSettings(IndexSettings indexSettings, String groupName) {
  Settings settings = indexSettings.getSettings().getAsSettings(groupName);
  if (settings.isEmpty()) {
    settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexSettings.getIndexVersionCreated()).build();
  }
  return settings;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public Similarity apply(Settings settings, Version indexCreatedVersion, ScriptService scriptService) {
  boolean discountOverlaps = settings.getAsBoolean(SimilarityProviders.DISCOUNT_OVERLAPS, true);
  Settings scriptSettings = settings.getAsSettings("script");
  Script script = Script.parse(scriptSettings);
  SimilarityScript.Factory scriptFactory = scriptService.compile(script, SimilarityScript.CONTEXT);
  Settings weightScriptSettings = settings.getAsSettings("weight_script");
  Script weightScript = null;
  SimilarityWeightScript.Factory weightScriptFactory = null;
  if (weightScriptSettings.isEmpty() == false) {
    weightScript = Script.parse(weightScriptSettings);
    weightScriptFactory = scriptService.compile(weightScript, SimilarityWeightScript.CONTEXT);
  }
  return new ScriptedSimilarity(
      weightScript == null ? null : weightScript.toString(),
          weightScriptFactory == null ? null : weightScriptFactory::newInstance,
              script.toString(), scriptFactory::newInstance, discountOverlaps);
}

代码示例来源:origin: harbby/presto-connectors

static Settings resolveHeaders(Settings settings) {
    Settings headers = settings.getAsSettings(PREFIX);
    return headers != null ? headers : Settings.EMPTY;
  }
}

代码示例来源:origin: NLPchina/elasticsearch-analysis-ansj

@Override
  public Tokenizer create() {
    Settings settings = indexSettings.getSettings().getAsSettings("index.analysis.tokenizer." + this.name);

    Map<String, String> args = settings.keySet().stream().collect(Collectors.toMap(k -> k, settings::get));
    if (args.isEmpty()) {
      args.putAll(AnsjElasticConfigurator.getDefaults());
      args.put("type", this.name);
    }

    LOG.debug("instance tokenizer settings : {}", args);

    return AnsjAnalyzer.getTokenizer(null, args);
  }
}

代码示例来源:origin: org.codelibs.elasticsearch.module/analysis-common

public PredicateTokenFilterScriptFactory(IndexSettings indexSettings, String name, Settings settings, ScriptService scriptService) {
  super(indexSettings, name, settings);
  Settings scriptSettings = settings.getAsSettings("script");
  Script script = Script.parse(scriptSettings);
  if (script.getType() != ScriptType.INLINE) {
    throw new IllegalArgumentException("Cannot use stored scripts in tokenfilter [" + name + "]");
  }
  this.factory = scriptService.compile(script, AnalysisPredicateScript.CONTEXT);
}

代码示例来源:origin: NLPchina/elasticsearch-analysis-ansj

@Inject
public AnsjAnalyzerProvider(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) {
  super(indexSettings, name, settings);
  Settings settings2 = indexSettings.getSettings().getAsSettings("index.analysis.tokenizer." + name());
  Map<String, String> args = settings2.keySet().stream().collect(Collectors.toMap(k -> k, settings2::get));
  if (args.isEmpty()) {
    args.putAll(AnsjElasticConfigurator.getDefaults());
    args.put("type", name());
  }
  LOG.debug("instance analyzer settings : {}", args);
  analyzer = new AnsjAnalyzer(args);
}

代码示例来源:origin: org.codelibs.elasticsearch.module/analysis-common

ScriptedConditionTokenFilterFactory(IndexSettings indexSettings, String name,
                      Settings settings, ScriptService scriptService) {
  super(indexSettings, name, settings);
  Settings scriptSettings = settings.getAsSettings("script");
  Script script = Script.parse(scriptSettings);
  if (script.getType() != ScriptType.INLINE) {
    throw new IllegalArgumentException("Cannot use stored scripts in tokenfilter [" + name + "]");
  }
  this.factory = scriptService.compile(script, AnalysisPredicateScript.CONTEXT);
  this.filterNames = settings.getAsList("filter");
  if (this.filterNames.isEmpty()) {
    throw new IllegalArgumentException("Empty list of filters provided to tokenfilter [" + name + "]");
  }
}

代码示例来源:origin: NLPchina/elasticsearch-analysis-ansj

private void init() {
  Path configFilePath = env.configFile().resolve("elasticsearch-analysis-ansj").resolve(CONFIG_FILE_NAME);
  LOG.info("try to load ansj config file: {}", configFilePath);
  if (!Files.exists(configFilePath)) {
    configFilePath = Paths.get(new File(AnsjElasticConfigurator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent(), "config").resolve(CONFIG_FILE_NAME);
    LOG.info("try to load ansj config file: {}", configFilePath);
  }
  Settings.Builder builder = Settings.builder();
  if (Files.exists(configFilePath)) {
    try {
      builder.loadFromPath(configFilePath);
      LOG.info("load ansj config: {}", configFilePath);
    } catch (IOException e) {
      LOG.error("load ansj config[{}] error: {}", configFilePath, e);
    }
  } else {
    LOG.warn("can't find ansj config file");
  }
  Settings settings = builder.build();
  path = settings.get("ansj_config");
  ansjSettings = settings.getAsSettings("ansj");
  configDir = env.configFile().toFile();
  flushConfig();
  // 进行一次测试分词
  preheat();
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Returns a {@link Settings} by groupName from {@link IndexSettings} or a default {@link Settings}
 * @param indexSettings an index settings
 * @param groupName tokenizer/token filter/char filter name
 * @return {@link Settings}
 */
public static Settings getSettingsFromIndexSettings(IndexSettings indexSettings, String groupName) {
  Settings settings = indexSettings.getSettings().getAsSettings(groupName);
  if (settings.isEmpty()) {
    settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexSettings.getIndexVersionCreated()).build();
  }
  return settings;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Returns a {@link Settings} by groupName from {@link IndexSettings} or a default {@link Settings}
 * @param indexSettings an index settings
 * @param groupName tokenizer/token filter/char filter name
 * @return {@link Settings}
 */
public static Settings getSettingsFromIndexSettings(IndexSettings indexSettings, String groupName) {
  Settings settings = indexSettings.getSettings().getAsSettings(groupName);
  if (settings.isEmpty()) {
    settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexSettings.getIndexVersionCreated()).build();
  }
  return settings;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Returns a {@link Settings} by groupName from {@link IndexSettings} or a default {@link Settings}
 * @param indexSettings an index settings
 * @param groupName tokenizer/token filter/char filter name
 * @return {@link Settings}
 */
public static Settings getSettingsFromIndexSettings(IndexSettings indexSettings, String groupName) {
  Settings settings = indexSettings.getSettings().getAsSettings(groupName);
  if (settings.isEmpty()) {
    settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexSettings.getIndexVersionCreated()).build();
  }
  return settings;
}

代码示例来源:origin: com.floragunn/search-guard-6

authorizationBackend = newInstance(
    authzBackendClazz,"z",
    Settings.builder().put(esSettings).put(ads.getAsSettings("authorization_backend.config")).build(), configPath);
authenticationBackend = newInstance(
    authBackendClazz,"c",
    Settings.builder().put(esSettings).put(ads.getAsSettings("authentication_backend.config")).build(), configPath);
  Settings.builder().put(esSettings).put(ads.getAsSettings("http_authenticator.config")).build(), configPath);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public Similarity apply(Settings settings, Version indexCreatedVersion, ScriptService scriptService) {
  boolean discountOverlaps = settings.getAsBoolean(SimilarityProviders.DISCOUNT_OVERLAPS, true);
  Settings scriptSettings = settings.getAsSettings("script");
  Script script = Script.parse(scriptSettings);
  SimilarityScript.Factory scriptFactory = scriptService.compile(script, SimilarityScript.CONTEXT);
  Settings weightScriptSettings = settings.getAsSettings("weight_script");
  Script weightScript = null;
  SimilarityWeightScript.Factory weightScriptFactory = null;
  if (weightScriptSettings.isEmpty() == false) {
    weightScript = Script.parse(weightScriptSettings);
    weightScriptFactory = scriptService.compile(weightScript, SimilarityWeightScript.CONTEXT);
  }
  return new ScriptedSimilarity(
      weightScript == null ? null : weightScript.toString(),
          weightScriptFactory == null ? null : weightScriptFactory::newInstance,
              script.toString(), scriptFactory::newInstance, discountOverlaps);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Similarity apply(Settings settings, Version indexCreatedVersion, ScriptService scriptService) {
  boolean discountOverlaps = settings.getAsBoolean(SimilarityProviders.DISCOUNT_OVERLAPS, true);
  Settings scriptSettings = settings.getAsSettings("script");
  Script script = Script.parse(scriptSettings);
  SimilarityScript.Factory scriptFactory = scriptService.compile(script, SimilarityScript.CONTEXT);
  Settings weightScriptSettings = settings.getAsSettings("weight_script");
  Script weightScript = null;
  SimilarityWeightScript.Factory weightScriptFactory = null;
  if (weightScriptSettings.isEmpty() == false) {
    weightScript = Script.parse(weightScriptSettings);
    weightScriptFactory = scriptService.compile(weightScript, SimilarityWeightScript.CONTEXT);
  }
  return new ScriptedSimilarity(
      weightScript == null ? null : weightScript.toString(),
          weightScriptFactory == null ? null : weightScriptFactory::newInstance,
              script.toString(), scriptFactory::newInstance, discountOverlaps);
}

代码示例来源:origin: com.floragunn/search-guard-6

if (OpenBSDBCrypt.checkPassword(hashed, array)) {
  final List<String> roles = cfg.getAsList(credentials.getUsername() + ".roles", Collections.emptyList());
  final Settings customAttributes = cfg.getAsSettings(credentials.getUsername() + ".attributes");

相关文章