org.elasticsearch.Version.indexCreated()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(74)

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

Version.indexCreated介绍

[英]Return the Version of Elasticsearch that has been used to create an index given its settings.
[中]根据Elasticsearch的设置,返回用于创建索引的版本。

代码示例

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

public Version indexCreatedVersion() {
    return Version.indexCreated(indexSettings);
  }
}

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

@Override
public AnalyzerProvider<?> get(IndexSettings indexSettings,
                Environment environment,
                String name,
                Settings settings) throws IOException {
  Version versionCreated = Version.indexCreated(settings);
  if (Version.CURRENT.equals(versionCreated) == false) {
    return super.get(indexSettings, environment, name, settings);
  } else {
    return current;
  }
}

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

protected FieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
           Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
  super(simpleName);
  assert indexSettings != null;
  this.indexCreatedVersion = Version.indexCreated(indexSettings);
  if (indexCreatedVersion.onOrAfter(Version.V_5_0_0_beta1)) {
    if (simpleName.isEmpty()) {
      throw new IllegalArgumentException("name cannot be empty string");
    }
  }
  fieldType.freeze();
  this.fieldType = fieldType;
  defaultFieldType.freeze();
  this.defaultFieldType = defaultFieldType;
  this.multiFields = multiFields;
  this.copyTo = Objects.requireNonNull(copyTo);
}

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

ObjectMapper(String name, String fullPath, boolean enabled, Nested nested, Dynamic dynamic,
    Boolean includeInAll, Map<String, Mapper> mappers, Settings settings) {
  super(name);
  assert settings != null;
  Version indexCreatedVersion = Version.indexCreated(settings);
  if (indexCreatedVersion.onOrAfter(Version.V_5_0_0_beta1)) {
    if (name.isEmpty()) {
      throw new IllegalArgumentException("name cannot be empty string");
    }
  }
  this.fullPath = fullPath;
  this.enabled = enabled;
  this.nested = nested;
  this.dynamic = dynamic;
  this.includeInAll = includeInAll;
  if (mappers == null) {
    this.mappers = new CopyOnWriteHashMap<>();
  } else {
    this.mappers = CopyOnWriteHashMap.copyOf(mappers);
  }
  this.nestedTypePathAsString = "__" + fullPath;
  this.nestedTypePathAsBytes = new BytesRef(nestedTypePathAsString);
  this.nestedTypeFilter = new TermQuery(new Term(TypeFieldMapper.NAME, nestedTypePathAsBytes));
}

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

@Override
public T get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException {
  Version versionCreated = Version.indexCreated(settings);
  synchronized (this) {
    T factory = cache.get(versionCreated);
    if (factory == null) {
      factory = create(versionCreated);
      cache.put(versionCreated, factory);
    }
    return factory;
  }
}

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

/**
 * Updates the settings and index metadata and notifies all registered settings consumers with the new settings iff at least one
 * setting has changed.
 *
 * @return <code>true</code> iff any setting has been updated otherwise <code>false</code>.
 */
public synchronized boolean updateIndexMetaData(IndexMetaData indexMetaData) {
  final Settings newSettings = indexMetaData.getSettings();
  if (version.equals(Version.indexCreated(newSettings)) == false) {
    throw new IllegalArgumentException("version mismatch on settings update expected: " + version + " but was: " +
      Version.indexCreated(newSettings));
  }
  final String newUUID = newSettings.get(IndexMetaData.SETTING_INDEX_UUID, IndexMetaData.INDEX_UUID_NA_VALUE);
  if (newUUID.equals(getUUID()) == false) {
    throw new IllegalArgumentException("uuid mismatch on settings update expected: " + getUUID() + " but was: " + newUUID);
  }
  this.indexMetaData = indexMetaData;
  final Settings newIndexSettings = Settings.builder().put(nodeSettings).put(newSettings).build();
  if (same(this.settings, newIndexSettings)) {
    // nothing to update, same settings
    return false;
  }
  scopedSettings.applySettings(newSettings);
  this.settings = newIndexSettings;
  return true;
}

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

public static Version parseAnalysisVersion(Settings indexSettings, Settings settings, Logger logger) {
  // check for explicit version on the specific analyzer component
  String sVersion = settings.get("version");
  if (sVersion != null) {
    return Lucene.parseVersion(sVersion, Version.LATEST, logger);
  }
  // check for explicit version on the index itself as default for all analysis components
  sVersion = indexSettings.get("index.analysis.version");
  if (sVersion != null) {
    return Lucene.parseVersion(sVersion, Version.LATEST, logger);
  }
  // resolve the analysis version based on the version the index was created with
  return org.elasticsearch.Version.indexCreated(indexSettings).luceneVersion;
}

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

if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(Version.V_6_5_0)) {
  assert mappingVersion : "mapping version should be present for indices created on or after 6.5.0";
if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(Version.V_6_5_0)) {
  assert settingsVersion : "settings version should be present for indices created on or after 6.5.0";

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

initialRecoveryFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, initialRecoveryMap);
Version indexCreatedVersion = Version.indexCreated(settings);
Version indexUpgradedVersion = settings.getAsVersion(IndexMetaData.SETTING_VERSION_UPGRADED, indexCreatedVersion);

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

@Nullable
  public Version indexCreatedVersion() {
    if (indexSettings == null) {
      return null;
    }
    return Version.indexCreated(indexSettings);
  }
}

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

/**
 * @return The lowest node version in the cluster when the index was created or <code>null</code> if that was unknown
 */
public Version getIndexCreatedVersion() {
  return Version.indexCreated(indexSettingsService.getSettings());
}

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

private TTLFieldMapper(MappedFieldType fieldType, EnabledAttributeMapper enabled, long defaultTTL,
             Settings indexSettings) {
  super(NAME, fieldType, Defaults.TTL_FIELD_TYPE, indexSettings);
  if (enabled.enabled && Version.indexCreated(indexSettings).onOrAfter(Version.V_5_0_0_alpha4)) {
    throw new IllegalArgumentException("[_ttl] is removed in 5.0. As a replacement, you should use time based indexes or cron a delete-by-query with a range query on a timestamp field.");
  }
  this.enabledState = enabled;
  this.defaultTTL = defaultTTL;
}

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

@Override
public AnalyzerProvider<?> get(IndexSettings indexSettings,
                Environment environment,
                String name,
                Settings settings) throws IOException {
  Version versionCreated = Version.indexCreated(settings);
  if (Version.CURRENT.equals(versionCreated) == false) {
    return super.get(indexSettings, environment, name, settings);
  } else {
    return current;
  }
}

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

public TokenizerFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException {
    Version indexVersion = Version.indexCreated(settings);
    if (!Version.CURRENT.equals(indexVersion)) {
      PreBuiltTokenizers preBuiltTokenizers = PreBuiltTokenizers.getOrDefault(name, null);
      if (preBuiltTokenizers != null) {
        return preBuiltTokenizers.getTokenizerFactory(indexVersion);
      }
    }

    return tokenizerFactory;
  }
}

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

@Override
  public CharFilterFactory create(String name, Settings settings) {
    Version indexVersion = Version.indexCreated(settings);
    if (!Version.CURRENT.equals(indexVersion)) {
      PreBuiltCharFilters preBuiltCharFilters = PreBuiltCharFilters.getOrDefault(name, null);
      if (preBuiltCharFilters != null) {
        return preBuiltCharFilters.getCharFilterFactory(indexVersion);
      }
    }

    return charFilterFactory;
  }
}

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

@Override
public T get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException {
  Version versionCreated = Version.indexCreated(settings);
  synchronized (this) {
    T factory = cache.get(versionCreated);
    if (factory == null) {
      factory = create(versionCreated);
      cache.put(versionCreated, factory);
    }
    return factory;
  }
}

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

NGramTokenizerFactory(Index index, Settings indexSettings, String name, Settings settings) {
  super(index, indexSettings, name, settings);
  this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
  this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
  this.matcher = parseTokenChars(settings.getAsArray("token_chars"));
  this.esVersion = org.elasticsearch.Version.indexCreated(indexSettings);
}

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

@Override
public AnalyzerProvider create(String name, Settings settings) {
  Version indexVersion = Version.indexCreated(settings);
  if (!Version.CURRENT.equals(indexVersion)) {
    PreBuiltAnalyzers preBuiltAnalyzers = PreBuiltAnalyzers.getOrDefault(name, null);
    if (preBuiltAnalyzers != null) {
      Analyzer analyzer = preBuiltAnalyzers.getAnalyzer(indexVersion);
      return new PreBuiltAnalyzerProvider(name, AnalyzerScope.INDICES, analyzer);
    }
  }
  return analyzerProvider;
}

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

private static MappedFieldType joinFieldTypeForParentType(String parentType, Settings indexSettings) {
  MappedFieldType parentJoinFieldType = Defaults.JOIN_FIELD_TYPE.clone();
  parentJoinFieldType.setNames(new MappedFieldType.Names(joinField(parentType)));
  Version indexCreated = Version.indexCreated(indexSettings);
  if (indexCreated.before(Version.V_2_0_0_beta1)) {
    parentJoinFieldType.setHasDocValues(false);
    parentJoinFieldType.setDocValuesType(DocValuesType.NONE);
  }
  parentJoinFieldType.freeze();
  return parentJoinFieldType;
}

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

protected void addIntegerFields(ParseContext context, List<IndexableField> fields, int value, float boost) {
  if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
    CustomIntegerNumericField field = new CustomIntegerNumericField(value, fieldType());
    if (boost != 1f && Version.indexCreated(context.indexSettings()).before(Version.V_5_0_0_alpha1)) {
      field.setBoost(boost);
    }
    fields.add(field);
  }
  if (fieldType().hasDocValues()) {
    addDocValue(context, fields, value);
  }
}

相关文章