Search in sources :

Example 26 with IndexSettings

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));
}
Also used : EnginePlugin(org.opensearch.plugins.EnginePlugin) IndexSettings(org.opensearch.index.IndexSettings) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata)

Example 27 with 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());
}
Also used : EnginePlugin(org.opensearch.plugins.EnginePlugin) IndexSettings(org.opensearch.index.IndexSettings) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) RetentionLeases(org.opensearch.index.seqno.RetentionLeases)

Example 28 with IndexSettings

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"));
}
Also used : Version(org.opensearch.Version) IndexSettings(org.opensearch.index.IndexSettings) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Example 29 with IndexSettings

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);
}
Also used : Version(org.opensearch.Version) IndexSettings(org.opensearch.index.IndexSettings) IndexSettings(org.opensearch.index.IndexSettings) Settings(org.opensearch.common.settings.Settings) TokenFilter(org.apache.lucene.analysis.TokenFilter)

Example 30 with IndexSettings

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);
}
Also used : Version(org.opensearch.Version) IndexSettings(org.opensearch.index.IndexSettings) IndexSettings(org.opensearch.index.IndexSettings) Settings(org.opensearch.common.settings.Settings) TokenFilter(org.apache.lucene.analysis.TokenFilter)

Aggregations

IndexSettings (org.opensearch.index.IndexSettings)195 Settings (org.opensearch.common.settings.Settings)137 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)72 IOException (java.io.IOException)39 Index (org.opensearch.index.Index)32 Matchers.containsString (org.hamcrest.Matchers.containsString)25 Version (org.opensearch.Version)23 Store (org.opensearch.index.store.Store)23 Map (java.util.Map)22 QueryShardContext (org.opensearch.index.query.QueryShardContext)22 OpenSearchException (org.opensearch.OpenSearchException)21 MapperService (org.opensearch.index.mapper.MapperService)20 ShardId (org.opensearch.index.shard.ShardId)19 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)17 List (java.util.List)17 IndexService (org.opensearch.index.IndexService)17 IndexShard (org.opensearch.index.shard.IndexShard)17 HashSet (java.util.HashSet)16 Query (org.apache.lucene.search.Query)16