use of org.opensearch.index.IndexSettings in project OpenSearch by opensearch-project.
the class EngineConfigFactoryTests method testCreateEngineConfigFromFactoryMultipleCustomTranslogDeletionPolicyFactoryIllegalStateException.
public void testCreateEngineConfigFromFactoryMultipleCustomTranslogDeletionPolicyFactoryIllegalStateException() {
IndexMetadata meta = IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1).build();
List<EnginePlugin> plugins = Arrays.asList(new FooEnginePlugin(), new BazEnginePlugin());
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test", meta.getSettings());
expectThrows(IllegalStateException.class, () -> new EngineConfigFactory(plugins, indexSettings));
}
use of org.opensearch.index.IndexSettings in project OpenSearch by opensearch-project.
the class EngineConfigFactoryTests method testCreateCodecServiceFromFactory.
public void testCreateCodecServiceFromFactory() {
IndexMetadata meta = IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1).build();
List<EnginePlugin> plugins = Arrays.asList(new BakEnginePlugin());
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test", meta.getSettings());
EngineConfigFactory factory = new EngineConfigFactory(plugins, indexSettings);
EngineConfig config = factory.newEngineConfig(null, null, indexSettings, null, null, null, null, null, null, null, null, null, null, TimeValue.timeValueMinutes(5), null, null, null, null, null, () -> new RetentionLeases(0, 0, Collections.emptyList()), null, null);
assertNotNull(config.getCodec());
}
use of org.opensearch.index.IndexSettings in project OpenSearch by opensearch-project.
the class AnalysisRegistryTests method testNoTypeOrTokenizerErrorMessage.
public void testNoTypeOrTokenizerErrorMessage() throws IOException {
Version version = VersionUtils.randomVersion(random());
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).putList("index.analysis.analyzer.test_analyzer.filter", new String[] { "lowercase", "stop", "shingle" }).putList("index.analysis.analyzer.test_analyzer.char_filter", new String[] { "html_strip" }).build();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> emptyAnalysisRegistry(settings).build(idxSettings));
assertThat(e.getMessage(), equalTo("analyzer [test_analyzer] must specify either an analyzer type, or a tokenizer"));
}
use of org.opensearch.index.IndexSettings in project OpenSearch by opensearch-project.
the class PreConfiguredTokenFilterTests method testCachingWithLuceneVersion.
public void testCachingWithLuceneVersion() throws IOException {
PreConfiguredTokenFilter pctf = PreConfiguredTokenFilter.luceneVersion("lucene_version", randomBoolean(), (tokenStream, luceneVersion) -> new TokenFilter(tokenStream) {
@Override
public boolean incrementToken() {
return false;
}
});
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test", Settings.EMPTY);
Version version1 = Version.CURRENT;
Settings settings1 = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version1).build();
TokenFilterFactory tff_v1_1 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "lucene_version", settings1);
TokenFilterFactory tff_v1_2 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "lucene_version", settings1);
assertSame(tff_v1_1, tff_v1_2);
byte major = VersionUtils.getPreviousVersion().major;
Version version2 = Version.fromString(major - 1 + ".0.0");
Settings settings2 = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version2).build();
TokenFilterFactory tff_v2 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "lucene_version", settings2);
assertNotSame(tff_v1_1, tff_v2);
}
use of org.opensearch.index.IndexSettings in project OpenSearch by opensearch-project.
the class PreConfiguredTokenFilterTests method testCachingWithOpenSearchVersion.
public void testCachingWithOpenSearchVersion() throws IOException {
PreConfiguredTokenFilter pctf = PreConfiguredTokenFilter.openSearchVersion("opensearch_version", randomBoolean(), (tokenStream, esVersion) -> new TokenFilter(tokenStream) {
@Override
public boolean incrementToken() {
return false;
}
});
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test", Settings.EMPTY);
Version version1 = VersionUtils.randomVersion(random());
Settings settings1 = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version1).build();
TokenFilterFactory tff_v1_1 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "opensearch_version", settings1);
TokenFilterFactory tff_v1_2 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "opensearch_version", settings1);
assertSame(tff_v1_1, tff_v1_2);
Version version2 = randomValueOtherThan(version1, () -> randomFrom(VersionUtils.allVersions()));
Settings settings2 = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version2).build();
TokenFilterFactory tff_v2 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "opensearch_version", settings2);
assertNotSame(tff_v1_1, tff_v2);
}
Aggregations