Package org.elasticsearch.common.settings.ImmutableSettings

Examples of org.elasticsearch.common.settings.ImmutableSettings.Builder


        for (int i = 0; i < iters; i++) {
            final Index index = new Index("test");
            final String name = "ngr";
            Version v = randomVersion(random());
            if (v.onOrAfter(Version.V_0_90_2)) {
                Builder builder = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", "letter,digit");
                boolean compatVersion = false;
                if ((compatVersion = random().nextBoolean())) {
                    builder.put("version", "4." + random().nextInt(3));
                }
                Settings settings = builder.build();
                Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build();
                Tokenizer nGramTokenizer = new NGramTokenizerFactory(index, indexSettings, name, settings).create();
                nGramTokenizer.setReader(new StringReader("foo bar"));
                if (compatVersion) {
                    assertThat(nGramTokenizer, instanceOf(Lucene43NGramTokenizer.class));
View Full Code Here


        for (int i = 0; i < iters; i++) {
            final Index index = new Index("test");
            final String name = "ngr";
            Version v = randomVersion(random());
            if (v.onOrAfter(Version.V_0_90_2)) {
                Builder builder = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3);
                boolean compatVersion = false;
                if ((compatVersion = random().nextBoolean())) {
                    builder.put("version", "4." + random().nextInt(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(index, indexSettings, name, settings).create(tokenizer);
                if (reverse) {
                    assertThat(edgeNGramTokenFilter, instanceOf(ReverseStringFilter.class));
                } else if (compatVersion) {
                    assertThat(edgeNGramTokenFilter, instanceOf(Lucene43EdgeNGramTokenFilter.class));
                } else {
                    assertThat(edgeNGramTokenFilter, instanceOf(EdgeNGramTokenFilter.class));
                }

            } else {
                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(index, indexSettings, name, settings).create(tokenizer);
                if (reverse) {
View Full Code Here

public class StopTokenFilterTests extends ElasticsearchTokenStreamTestCase {

    @Test(expected = ProvisionException.class)
    public void testPositionIncrementSetting() throws IOException {
        Builder builder = ImmutableSettings.settingsBuilder().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");
        }
        Settings settings = builder.build();
        AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(settings);
        analysisService.tokenFilter("my_stop");
    }
View Full Code Here

        analysisService.tokenFilter("my_stop");
    }

    @Test
    public void testCorrectPositionIncrementSetting() throws IOException {
        Builder builder = ImmutableSettings.settingsBuilder().put("index.analysis.filter.my_stop.type", "stop");
        int thingToDo = random().nextInt(3);
        if (thingToDo == 0) {
            builder.put("index.analysis.filter.my_stop.version", Version.LATEST);
        } else if (thingToDo == 1) {
            builder.put("index.analysis.filter.my_stop.version", Version.LUCENE_4_0);
            if (random().nextBoolean()) {
                builder.put("index.analysis.filter.my_stop.enable_position_increments", true);
            }
        } else {
            // don't specify
        }
        AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromSettings(builder.build());
        TokenFilterFactory tokenFilter = analysisService.tokenFilter("my_stop");
        assertThat(tokenFilter, instanceOf(StopTokenFilterFactory.class));
        Tokenizer tokenizer = new WhitespaceTokenizer();
        tokenizer.setReader(new StringReader("foo bar"));
        TokenStream create = tokenFilter.create(tokenizer);
View Full Code Here

    }

    @Override
    protected void doStart() throws ElasticsearchException {
        try {
            Builder builder = ImmutableSettings.builder();
            for (String configName : new String [] {
                    PLUGIN_CONFIG_FILE_NAME + ".yml",
                    PLUGIN_CONFIG_FILE_NAME + ".json",
                    PLUGIN_CONFIG_FILE_NAME + ".properties"
            }) {
                try {
                    builder.loadFromUrl(environment.resolveConfig(configName));
                } catch (FailedToResolveConfigException e) {
                    // fall-through
                } catch (NoClassDefFoundError e) {
                    logger.warn("Could not parse: {}", e, configName);
                }
            }
            Settings c2Settings = builder.build();

            final String resourcesPath = c2Settings.get(DEFAULT_RESOURCES_PROPERTY_NAME, ".");
            final File resourcesDir;
            if (new File(resourcesPath).isAbsolute()) {
                resourcesDir = new File(resourcesPath);
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.settings.ImmutableSettings.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.