Search in sources :

Example 1 with Builder

use of org.elasticsearch.common.settings.Settings.Builder in project elasticsearch by elastic.

the class NGramTokenizerFactoryTests method testBackwardsCompatibilityEdgeNgramTokenFilter.

public void testBackwardsCompatibilityEdgeNgramTokenFilter() throws Exception {
    int iters = scaledRandomIntBetween(20, 100);
    for (int i = 0; i < iters; i++) {
        final Index index = new Index("test", "_na_");
        final String name = "ngr";
        Version v = randomVersion(random());
        Builder builder = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3);
        boolean reverse = random().nextBoolean();
        if (reverse) {
            builder.put("side", "back");
        }
        Settings settings = builder.build();
        Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build();
        Tokenizer tokenizer = new MockTokenizer();
        tokenizer.setReader(new StringReader("foo bar"));
        TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(IndexSettingsModule.newIndexSettings(index, indexSettings), null, name, settings).create(tokenizer);
        if (reverse) {
            assertThat(edgeNGramTokenFilter, instanceOf(ReverseStringFilter.class));
        } else {
            assertThat(edgeNGramTokenFilter, instanceOf(EdgeNGramTokenFilter.class));
        }
    }
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) EdgeNGramTokenFilter(org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter) Builder(org.elasticsearch.common.settings.Settings.Builder) Index(org.elasticsearch.index.Index) MockTokenizer(org.apache.lucene.analysis.MockTokenizer) Version(org.elasticsearch.Version) StringReader(java.io.StringReader) ReverseStringFilter(org.apache.lucene.analysis.reverse.ReverseStringFilter) Tokenizer(org.apache.lucene.analysis.Tokenizer) MockTokenizer(org.apache.lucene.analysis.MockTokenizer) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings)

Example 2 with Builder

use of org.elasticsearch.common.settings.Settings.Builder in project elasticsearch by elastic.

the class StopTokenFilterTests method testPositionIncrementSetting.

public void testPositionIncrementSetting() throws IOException {
    Builder builder = Settings.builder().put("index.analysis.filter.my_stop.type", "stop").put("index.analysis.filter.my_stop.enable_position_increments", false);
    if (random().nextBoolean()) {
        builder.put("index.analysis.filter.my_stop.version", "5.0");
    }
    builder.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString());
    Settings settings = builder.build();
    try {
        AnalysisTestsHelper.createTestAnalysisFromSettings(settings);
        fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("enable_position_increments is not supported anymore"));
    }
}
Also used : Builder(org.elasticsearch.common.settings.Settings.Builder) Settings(org.elasticsearch.common.settings.Settings)

Example 3 with Builder

use of org.elasticsearch.common.settings.Settings.Builder in project elasticsearch by elastic.

the class InternalTestCluster method getSettings.

private Settings getSettings(int nodeOrdinal, long nodeSeed, Settings others) {
    Builder builder = Settings.builder().put(defaultSettings).put(getRandomNodeSettings(nodeSeed));
    Settings settings = nodeConfigurationSource.nodeSettings(nodeOrdinal);
    if (settings != null) {
        if (settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()) != null) {
            throw new IllegalStateException("Tests must not set a '" + ClusterName.CLUSTER_NAME_SETTING.getKey() + "' as a node setting set '" + ClusterName.CLUSTER_NAME_SETTING.getKey() + "': [" + settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()) + "]");
        }
        builder.put(settings);
    }
    if (others != null) {
        builder.put(others);
    }
    builder.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName);
    return builder.build();
}
Also used : XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Builder(org.elasticsearch.common.settings.Settings.Builder) RecoverySettings(org.elasticsearch.indices.recovery.RecoverySettings) TransportSettings(org.elasticsearch.transport.TransportSettings) DiskThresholdSettings(org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 4 with Builder

use of org.elasticsearch.common.settings.Settings.Builder in project elasticsearch by elastic.

the class InternalTestCluster method startCoordinatingOnlyNode.

public synchronized String startCoordinatingOnlyNode(Settings settings) {
    // currently unused
    ensureOpen();
    Builder builder = Settings.builder().put(settings).put(Node.NODE_MASTER_SETTING.getKey(), false).put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_INGEST_SETTING.getKey(), false);
    return startNode(builder);
}
Also used : XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Builder(org.elasticsearch.common.settings.Settings.Builder)

Example 5 with Builder

use of org.elasticsearch.common.settings.Settings.Builder in project elasticsearch by elastic.

the class InternalTestCluster method getRandomNodeSettings.

private Settings getRandomNodeSettings(long seed) {
    Random random = new Random(seed);
    Builder builder = Settings.builder();
    builder.put(Transport.TRANSPORT_TCP_COMPRESS.getKey(), rarely(random));
    if (random.nextBoolean()) {
        builder.put("cache.recycler.page.type", RandomPicks.randomFrom(random, PageCacheRecycler.Type.values()));
    }
    if (random.nextInt(10) == 0) {
        // 10% of the nodes have a very frequent check interval
        builder.put(SearchService.KEEPALIVE_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(10 + random.nextInt(2000)).getStringRep());
    } else if (random.nextInt(10) != 0) {
        // 90% of the time - 10% of the time we don't set anything
        builder.put(SearchService.KEEPALIVE_INTERVAL_SETTING.getKey(), TimeValue.timeValueSeconds(10 + random.nextInt(5 * 60)).getStringRep());
    }
    if (random.nextBoolean()) {
        // sometimes set a
        builder.put(SearchService.DEFAULT_KEEPALIVE_SETTING.getKey(), TimeValue.timeValueSeconds(100 + random.nextInt(5 * 60)).getStringRep());
    }
    builder.put(EsExecutors.PROCESSORS_SETTING.getKey(), 1 + random.nextInt(3));
    if (random.nextBoolean()) {
        if (random.nextBoolean()) {
            builder.put("indices.fielddata.cache.size", 1 + random.nextInt(1000), ByteSizeUnit.MB);
        }
    }
    // randomize tcp settings
    if (random.nextBoolean()) {
        builder.put(TcpTransport.CONNECTIONS_PER_NODE_RECOVERY.getKey(), random.nextInt(2) + 1);
        builder.put(TcpTransport.CONNECTIONS_PER_NODE_BULK.getKey(), random.nextInt(3) + 1);
        builder.put(TcpTransport.CONNECTIONS_PER_NODE_REG.getKey(), random.nextInt(6) + 1);
    }
    if (random.nextBoolean()) {
        builder.put(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey(), new TimeValue(RandomNumbers.randomIntBetween(random, 10, 30), TimeUnit.SECONDS));
    }
    if (random.nextInt(10) == 0) {
        builder.put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING.getKey(), "noop");
        builder.put(HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING.getKey(), "noop");
    }
    if (random.nextBoolean()) {
        if (random.nextInt(10) == 0) {
            // do something crazy slow here
            builder.put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), new ByteSizeValue(RandomNumbers.randomIntBetween(random, 1, 10), ByteSizeUnit.MB));
        } else {
            builder.put(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey(), new ByteSizeValue(RandomNumbers.randomIntBetween(random, 10, 200), ByteSizeUnit.MB));
        }
    }
    if (random.nextBoolean()) {
        builder.put(TcpTransport.PING_SCHEDULE.getKey(), RandomNumbers.randomIntBetween(random, 100, 2000) + "ms");
    }
    if (random.nextBoolean()) {
        builder.put(ScriptService.SCRIPT_CACHE_SIZE_SETTING.getKey(), RandomNumbers.randomIntBetween(random, 0, 2000));
    }
    if (random.nextBoolean()) {
        builder.put(ScriptService.SCRIPT_CACHE_EXPIRE_SETTING.getKey(), TimeValue.timeValueMillis(RandomNumbers.randomIntBetween(random, 750, 10000000)).getStringRep());
    }
    return builder.build();
}
Also used : Random(java.util.Random) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Builder(org.elasticsearch.common.settings.Settings.Builder) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) TimeValue(org.elasticsearch.common.unit.TimeValue)

Aggregations

Builder (org.elasticsearch.common.settings.Settings.Builder)38 Settings (org.elasticsearch.common.settings.Settings)17 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)16 XContentFactory.jsonBuilder (org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder)10 IndexRequestBuilder (org.elasticsearch.action.index.IndexRequestBuilder)8 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)8 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)8 SearchResponse (org.elasticsearch.action.search.SearchResponse)7 InetSocketTransportAddress (org.elasticsearch.common.transport.InetSocketTransportAddress)7 DiskThresholdSettings (org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings)6 RecoverySettings (org.elasticsearch.indices.recovery.RecoverySettings)6 TransportSettings (org.elasticsearch.transport.TransportSettings)6 ElasticsearchException (org.elasticsearch.ElasticsearchException)5 TransportClient (org.elasticsearch.client.transport.TransportClient)5 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)5 Node (org.elasticsearch.node.Node)5 ElasticsearchAssertions.assertSearchResponse (org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 QueryRescorerBuilder (org.elasticsearch.search.rescore.QueryRescorerBuilder)4