Search in sources :

Example 96 with Settings

use of org.opensearch.common.settings.Settings in project OpenSearch by opensearch-project.

the class TokenCountFieldMapperIntegrationIT method init.

private void init() throws IOException {
    Settings.Builder settings = Settings.builder();
    settings.put(indexSettings());
    settings.put("index.analysis.analyzer.mock_english.tokenizer", "standard");
    settings.put("index.analysis.analyzer.mock_english.filter", "stop");
    prepareCreate("test").setSettings(settings).addMapping("test", jsonBuilder().startObject().startObject("test").startObject("properties").startObject("foo").field("type", "text").field("store", storeCountedFields).field("analyzer", "simple").startObject("fields").startObject("token_count").field("type", "token_count").field("analyzer", "standard").field("store", true).endObject().startObject("token_count_unstored").field("type", "token_count").field("analyzer", "standard").endObject().startObject("token_count_with_doc_values").field("type", "token_count").field("analyzer", "standard").field("doc_values", true).endObject().startObject("token_count_without_position_increments").field("type", "token_count").field("analyzer", "mock_english").field("enable_position_increments", false).field("store", true).endObject().endObject().endObject().endObject().endObject().endObject()).get();
    ensureGreen();
    assertEquals(DocWriteResponse.Result.CREATED, prepareIndex("single", "I have four terms").get().getResult());
    BulkResponse bulk = client().prepareBulk().add(prepareIndex("bulk1", "bulk three terms")).add(prepareIndex("bulk2", "this has five bulk terms")).get();
    assertFalse(bulk.buildFailureMessage(), bulk.hasFailures());
    assertEquals(DocWriteResponse.Result.CREATED, prepareIndex("multi", "two terms", "wow now I have seven lucky terms").get().getResult());
    bulk = client().prepareBulk().add(prepareIndex("multibulk1", "one", "oh wow now I have eight unlucky terms")).add(prepareIndex("multibulk2", "six is a bunch of terms", "ten!  ten terms is just crazy!  too many too count!")).get();
    assertFalse(bulk.buildFailureMessage(), bulk.hasFailures());
    assertThat(refresh().getFailedShards(), equalTo(0));
}
Also used : BulkResponse(org.opensearch.action.bulk.BulkResponse) Settings(org.opensearch.common.settings.Settings)

Example 97 with Settings

use of org.opensearch.common.settings.Settings in project OpenSearch by opensearch-project.

the class RankFeatureFieldTypeTests method testFetchSourceValue.

public void testFetchSourceValue() throws IOException {
    Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id).build();
    Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath());
    MappedFieldType mapper = new RankFeatureFieldMapper.Builder("field").build(context).fieldType();
    assertEquals(Collections.singletonList(3.14f), fetchSourceValue(mapper, 3.14));
    assertEquals(Collections.singletonList(42.9f), fetchSourceValue(mapper, "42.9"));
}
Also used : Settings(org.opensearch.common.settings.Settings)

Example 98 with Settings

use of org.opensearch.common.settings.Settings in project OpenSearch by opensearch-project.

the class RegexLimitTests method beforeClass.

@BeforeClass
public static void beforeClass() {
    Settings settings = Settings.builder().put(CompilerSettings.REGEX_LIMIT_FACTOR.getKey(), 1).build();
    SCRIPT_ENGINE = new PainlessScriptEngine(settings, newDefaultContexts());
}
Also used : Settings(org.opensearch.common.settings.Settings) BeforeClass(org.junit.BeforeClass)

Example 99 with Settings

use of org.opensearch.common.settings.Settings in project OpenSearch by opensearch-project.

the class ReindexRestClientSslTests method testClientSucceedsWithCertificateAuthorities.

public void testClientSucceedsWithCertificateAuthorities() throws IOException {
    final List<Thread> threads = new ArrayList<>();
    final Path ca = getDataPath("ca.pem");
    final Settings settings = Settings.builder().put("path.home", createTempDir()).putList("reindex.ssl.certificate_authorities", ca.toString()).put("reindex.ssl.supported_protocols", "TLSv1.2").build();
    final Environment environment = TestEnvironment.newEnvironment(settings);
    final ReindexSslConfig ssl = new ReindexSslConfig(settings, environment, mock(ResourceWatcherService.class));
    try (RestClient client = Reindexer.buildRestClient(getRemoteInfo(), ssl, 1L, threads)) {
        final Response response = client.performRequest(new Request("GET", "/"));
        assertThat(response.getStatusLine().getStatusCode(), Matchers.is(200));
    }
}
Also used : Path(java.nio.file.Path) Response(org.opensearch.client.Response) ArrayList(java.util.ArrayList) RestClient(org.opensearch.client.RestClient) Request(org.opensearch.client.Request) TestEnvironment(org.opensearch.env.TestEnvironment) Environment(org.opensearch.env.Environment) ResourceWatcherService(org.opensearch.watcher.ResourceWatcherService) Settings(org.opensearch.common.settings.Settings)

Example 100 with Settings

use of org.opensearch.common.settings.Settings in project OpenSearch by opensearch-project.

the class ReindexRestClientSslTests method testClientSucceedsWithVerificationDisabled.

public void testClientSucceedsWithVerificationDisabled() throws IOException {
    assumeFalse("Cannot disable verification in FIPS JVM", inFipsJvm());
    final List<Thread> threads = new ArrayList<>();
    final Settings settings = Settings.builder().put("path.home", createTempDir()).put("reindex.ssl.verification_mode", "NONE").put("reindex.ssl.supported_protocols", "TLSv1.2").build();
    final Environment environment = TestEnvironment.newEnvironment(settings);
    final ReindexSslConfig ssl = new ReindexSslConfig(settings, environment, mock(ResourceWatcherService.class));
    try (RestClient client = Reindexer.buildRestClient(getRemoteInfo(), ssl, 1L, threads)) {
        final Response response = client.performRequest(new Request("GET", "/"));
        assertThat(response.getStatusLine().getStatusCode(), Matchers.is(200));
    }
}
Also used : Response(org.opensearch.client.Response) ArrayList(java.util.ArrayList) RestClient(org.opensearch.client.RestClient) Request(org.opensearch.client.Request) TestEnvironment(org.opensearch.env.TestEnvironment) Environment(org.opensearch.env.Environment) ResourceWatcherService(org.opensearch.watcher.ResourceWatcherService) Settings(org.opensearch.common.settings.Settings)

Aggregations

Settings (org.opensearch.common.settings.Settings)1293 IndexSettings (org.opensearch.index.IndexSettings)304 Matchers.containsString (org.hamcrest.Matchers.containsString)221 ClusterSettings (org.opensearch.common.settings.ClusterSettings)196 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)158 ClusterState (org.opensearch.cluster.ClusterState)150 IOException (java.io.IOException)127 ArrayList (java.util.ArrayList)127 Version (org.opensearch.Version)122 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)121 List (java.util.List)108 Index (org.opensearch.index.Index)106 Path (java.nio.file.Path)104 Map (java.util.Map)97 HashMap (java.util.HashMap)95 HashSet (java.util.HashSet)86 ShardId (org.opensearch.index.shard.ShardId)86 IndexScopedSettings (org.opensearch.common.settings.IndexScopedSettings)83 Environment (org.opensearch.env.Environment)82 ShardRouting (org.opensearch.cluster.routing.ShardRouting)71