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));
}
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"));
}
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());
}
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));
}
}
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));
}
}
Aggregations