Java Code Examples for org.elasticsearch.common.settings.Settings#getAsBoolean()

The following examples show how to use org.elasticsearch.common.settings.Settings#getAsBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathHierarchyTokenizerFactory.java    From crate with Apache License 2.0 7 votes vote down vote up
PathHierarchyTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    bufferSize = settings.getAsInt("buffer_size", 1024);
    String delimiter = settings.get("delimiter");
    if (delimiter == null) {
        this.delimiter = PathHierarchyTokenizer.DEFAULT_DELIMITER;
    } else if (delimiter.length() != 1) {
        throw new IllegalArgumentException("delimiter must be a one char value");
    } else {
        this.delimiter = delimiter.charAt(0);
    }

    String replacement = settings.get("replacement");
    if (replacement == null) {
        this.replacement = this.delimiter;
    } else if (replacement.length() != 1) {
        throw new IllegalArgumentException("replacement must be a one char value");
    } else {
        this.replacement = replacement.charAt(0);
    }
    this.skip = settings.getAsInt("skip", PathHierarchyTokenizer.DEFAULT_SKIP);
    this.reverse = settings.getAsBoolean("reverse", false);
}
 
Example 2
Source File: CJKBigramFilterFactory.java    From crate with Apache License 2.0 6 votes vote down vote up
CJKBigramFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    outputUnigrams = settings.getAsBoolean("output_unigrams", false);
    final List<String> asArray = settings.getAsList("ignored_scripts");
    Set<String> scripts = new HashSet<>(Arrays.asList("han", "hiragana", "katakana", "hangul"));
    if (asArray != null) {
        scripts.removeAll(asArray);
    }
    int flags = 0;
    for (String script : scripts) {
        if ("han".equals(script)) {
            flags |= CJKBigramFilter.HAN;
        } else if ("hiragana".equals(script)) {
            flags |= CJKBigramFilter.HIRAGANA;
        } else if ("katakana".equals(script)) {
            flags |= CJKBigramFilter.KATAKANA;
        } else if ("hangul".equals(script)) {
            flags |= CJKBigramFilter.HANGUL;
        }
    }
    this.flags = flags;
}
 
Example 3
Source File: HunspellTokenFilterFactory.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public HunspellTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings, HunspellService hunspellService)  {
    super(index, indexSettingsService.getSettings(), name, settings);

    String locale = settings.get("locale", settings.get("language", settings.get("lang", null)));
    if (locale == null) {
        throw new IllegalArgumentException("missing [locale | language | lang] configuration for hunspell token filter");
    }

    dictionary = hunspellService.getDictionary(locale);
    if (dictionary == null) {
        throw new IllegalArgumentException(String.format(Locale.ROOT, "Unknown hunspell dictionary for locale [%s]", locale));
    }

    dedup = settings.getAsBoolean("dedup", true);
    longestOnly = settings.getAsBoolean("longest_only", false);
}
 
Example 4
Source File: AutoCreateIndex.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public AutoCreateIndex(Settings settings, IndexNameExpressionResolver resolver) {
    this.resolver = resolver;
    dynamicMappingDisabled = !settings.getAsBoolean(MapperService.INDEX_MAPPER_DYNAMIC_SETTING, MapperService.INDEX_MAPPER_DYNAMIC_DEFAULT);
    String value = settings.get("action.auto_create_index");
    if (value == null || Booleans.isExplicitTrue(value)) {
        needToCheck = true;
        globallyDisabled = false;
        matches = null;
        matches2 = null;
    } else if (Booleans.isExplicitFalse(value)) {
        needToCheck = false;
        globallyDisabled = true;
        matches = null;
        matches2 = null;
    } else {
        needToCheck = true;
        globallyDisabled = false;
        matches = Strings.commaDelimitedListToStringArray(value);
        matches2 = new String[matches.length];
        for (int i = 0; i < matches.length; i++) {
            matches2[i] = matches[i].substring(1);
        }
    }
}
 
Example 5
Source File: ResourceWatcherService.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Inject
public ResourceWatcherService(Settings settings, ThreadPool threadPool) {
    super(settings);
    this.enabled = settings.getAsBoolean("resource.reload.enabled", true);
    this.threadPool = threadPool;

    TimeValue interval = settings.getAsTime("resource.reload.interval.low", Frequency.LOW.interval);
    lowMonitor = new ResourceMonitor(interval, Frequency.LOW);
    interval = settings.getAsTime("resource.reload.interval.medium", settings.getAsTime("resource.reload.interval", Frequency.MEDIUM.interval));
    mediumMonitor = new ResourceMonitor(interval, Frequency.MEDIUM);
    interval = settings.getAsTime("resource.reload.interval.high", Frequency.HIGH.interval);
    highMonitor = new ResourceMonitor(interval, Frequency.HIGH);

    logRemovedSetting("watcher.enabled", "resource.reload.enabled");
    logRemovedSetting("watcher.interval", "resource.reload.interval");
    logRemovedSetting("watcher.interval.low", "resource.reload.interval.low");
    logRemovedSetting("watcher.interval.medium", "resource.reload.interval.medium");
    logRemovedSetting("watcher.interval.high", "resource.reload.interval.high");
}
 
Example 6
Source File: LDAPAuthenticationBackend.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
static LdapEntry exists(final String user, Connection ldapConnection, Settings settings,
        List<Map.Entry<String, Settings>> userBaseSettings) throws Exception {

    if (settings.getAsBoolean(ConfigConstants.LDAP_FAKE_LOGIN_ENABLED, false)
            || settings.getAsBoolean(ConfigConstants.LDAP_SEARCH_ALL_BASES, false)
            || settings.hasValue(ConfigConstants.LDAP_AUTHC_USERBASE)) {
        return existsSearchingAllBases(user, ldapConnection, userBaseSettings);
    } else {
        return existsSearchingUntilFirstHit(user, ldapConnection, userBaseSettings);
    }

}
 
Example 7
Source File: LengthTokenFilterFactory.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public LengthTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    min = settings.getAsInt("min", 0);
    max = settings.getAsInt("max", Integer.MAX_VALUE);
    if (version.onOrAfter(Version.LUCENE_4_4) && settings.get(ENABLE_POS_INC_KEY) != null) {
        throw new IllegalArgumentException(ENABLE_POS_INC_KEY + " is not supported anymore. Please fix your analysis chain or use"
                + " an older compatibility version (<=4.3) but beware that it might cause highlighting bugs.");
    }
    enablePositionIncrements = version.onOrAfter(Version.LUCENE_4_4) ? true : settings.getAsBoolean(ENABLE_POS_INC_KEY, true);
}
 
Example 8
Source File: InternalClusterInfoService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public InternalClusterInfoService(Settings settings, NodeSettingsService nodeSettingsService,
                                  TransportNodesStatsAction transportNodesStatsAction,
                                  TransportIndicesStatsAction transportIndicesStatsAction, ClusterService clusterService,
                                  ThreadPool threadPool) {
    super(settings);
    this.leastAvailableSpaceUsages = Collections.emptyMap();
    this.mostAvailableSpaceUsages = Collections.emptyMap();
    this.shardRoutingToDataPath = Collections.emptyMap();
    this.shardSizes = Collections.emptyMap();
    this.transportNodesStatsAction = transportNodesStatsAction;
    this.transportIndicesStatsAction = transportIndicesStatsAction;
    this.clusterService = clusterService;
    this.threadPool = threadPool;
    this.updateFrequency = settings.getAsTime(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL);

    this.enabled = settings.getAsBoolean(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED, true);
    this.updateFrequency = settings.getAsTime(INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL);
    this.fetchTimeout = settings.getAsTime(INTERNAL_CLUSTER_INFO_TIMEOUT, DEFAULT_TIMEOUT);
    this.enabled = settings.getAsBoolean(
            DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED,
            DiskThresholdDecider.DEFAULT_THRESHOLD_ENABLED);
    nodeSettingsService.addListener(new ApplySettings());

    // Add InternalClusterInfoService to listen for Master changes
    this.clusterService.add((LocalNodeMasterListener)this);
    // Add to listen for state changes (when nodes are added)
    this.clusterService.add((ClusterStateListener)this);
}
 
Example 9
Source File: TransportIndexAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public TransportIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
                            IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction,
                            TransportCreateIndexAction createIndexAction, MappingUpdatedAction mappingUpdatedAction,
                            ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
                            AutoCreateIndex autoCreateIndex, FsService fsService) {
    super(settings, IndexAction.NAME, transportService, clusterService, indicesService, threadPool, shardStateAction, mappingUpdatedAction,
            actionFilters, indexNameExpressionResolver, IndexRequest.class, IndexRequest.class, ThreadPool.Names.INDEX);
    this.createIndexAction = createIndexAction;
    this.autoCreateIndex = autoCreateIndex;
    this.allowIdGeneration = settings.getAsBoolean("action.allow_id_generation", true);
    this.clusterService = clusterService;
    this.fsService = fsService;
}
 
Example 10
Source File: DiscoverySettings.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public DiscoverySettings(Settings settings, NodeSettingsService nodeSettingsService) {
    super(settings);
    nodeSettingsService.addListener(new ApplySettings());
    this.noMasterBlock = parseNoMasterBlock(settings.get(NO_MASTER_BLOCK, DEFAULT_NO_MASTER_BLOCK));
    this.publishTimeout = settings.getAsTime(PUBLISH_TIMEOUT, publishTimeout);
    this.publishDiff = settings.getAsBoolean(PUBLISH_DIFF_ENABLE, DEFAULT_PUBLISH_DIFF_ENABLE);
}
 
Example 11
Source File: IdFieldMapper.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private static MappedFieldType idFieldType(Settings indexSettings, MappedFieldType existing) {
    if (existing != null) {
        return existing.clone();
    }
    MappedFieldType fieldType = Defaults.FIELD_TYPE.clone();
    boolean pre2x = Version.indexCreated(indexSettings).before(Version.V_2_0_0_beta1);
    if (pre2x && indexSettings.getAsBoolean("index.mapping._id.indexed", true) == false) {
        fieldType.setTokenized(false);
    }
    return fieldType;
}
 
Example 12
Source File: BM25SimilarityProvider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public BM25SimilarityProvider(@Assisted String name, @Assisted Settings settings) {
    super(name);
    float k1 = settings.getAsFloat("k1", 1.2f);
    float b = settings.getAsFloat("b", 0.75f);
    boolean discountOverlaps = settings.getAsBoolean("discount_overlaps", true);

    this.similarity = new BM25Similarity(k1, b);
    this.similarity.setDiscountOverlaps(discountOverlaps);
}
 
Example 13
Source File: DiskThresholdDecider.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public DiskThresholdDecider(Settings settings, NodeSettingsService nodeSettingsService, ClusterInfoService infoService, Client client) {
    super(settings);
    String lowWatermark = settings.get(CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK,
            DEFAULT_LOW_DISK_WATERMARK);
    String highWatermark = settings.get(CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK,
            DEFAULT_HIGH_DISK_WATERMARK);

    if (!validWatermarkSetting(lowWatermark, CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK)) {
        throw new ElasticsearchParseException("unable to parse low watermark [{}]", lowWatermark);
    }
    if (!validWatermarkSetting(highWatermark, CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK)) {
        throw new ElasticsearchParseException("unable to parse high watermark [{}]", highWatermark);
    }
    // Watermark is expressed in terms of used data, but we need "free" data watermark
    this.freeDiskThresholdLow = 100.0 - thresholdPercentageFromWatermark(lowWatermark);
    this.freeDiskThresholdHigh = 100.0 - thresholdPercentageFromWatermark(highWatermark);

    this.freeBytesThresholdLow = thresholdBytesFromWatermark(lowWatermark, CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK);
    this.freeBytesThresholdHigh = thresholdBytesFromWatermark(highWatermark, CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK);
    this.includeRelocations = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS,
            DEFAULT_INCLUDE_RELOCATIONS);
    this.rerouteInterval = settings.getAsTime(CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL, TimeValue.timeValueSeconds(60));

    this.enabled = settings.getAsBoolean(CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED,
            DEFAULT_THRESHOLD_ENABLED);
    nodeSettingsService.addListener(new ApplySettings());
    infoService.addListener(new DiskListener(client));
}
 
Example 14
Source File: AutoPhrasingTokenFilterFactory.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 5 votes vote down vote up
public AutoPhrasingTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
    super(indexSettings, name, settings);
    this.phraseSetFiles = settings.get("phrases");
    this.ignoreCase = settings.getAsBoolean("ignoreCase", false);
    this.emitSingleTokens = settings.getAsBoolean("includeTokens", false);
    this.replaceWhitespaceWith = settings.get("replaceWhitespaceWith");
}
 
Example 15
Source File: PatternCaptureGroupTokenFilterFactory.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public PatternCaptureGroupTokenFilterFactory(Index index, Settings indexSettings, String name, Settings settings) {
    super(index, indexSettings, name, settings);
    String[] regexes = settings.getAsArray(PATTERNS_KEY, null, false);
    if (regexes == null) {
        throw new IllegalArgumentException("required setting '" + PATTERNS_KEY + "' is missing for token filter [" + name + "]");
    }
    patterns = new Pattern[regexes.length];
    for (int i = 0; i < regexes.length; i++) {
        patterns[i] = Pattern.compile(regexes[i]);
    }

    preserveOriginal = settings.getAsBoolean(PRESERVE_ORIG_KEY, true);
}
 
Example 16
Source File: PrimaryShardAllocator.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Return {@code true} if the index is configured to allow shards to be
 * recovered on any node
 */
private boolean recoverOnAnyNode(Settings idxSettings) {
    return IndexMetaData.isOnSharedFilesystem(idxSettings) &&
            idxSettings.getAsBoolean(IndexMetaData.SETTING_SHARED_FS_ALLOW_RECOVERY_ON_ANY_NODE, false);
}
 
Example 17
Source File: IndexMetaData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static boolean isIndexUsingDLEngine(Settings settings) {
    return settings.getAsBoolean(IndexMetaData.SETTING_USING_DL_ENGINE, SETTING_USING_DL_ENGINE_DEFAULT);
}
 
Example 18
Source File: BoolSetting.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean extract(Settings settings) {
    return settings.getAsBoolean(settingName(), defaultValue());
}
 
Example 19
Source File: QueryStringQueryParser.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public QueryStringQueryParser(Settings settings) {
    this.defaultAnalyzeWildcard = settings.getAsBoolean("indices.query.query_string.analyze_wildcard", QueryParserSettings.DEFAULT_ANALYZE_WILDCARD);
    this.defaultAllowLeadingWildcard = settings.getAsBoolean("indices.query.query_string.allowLeadingWildcard", QueryParserSettings.DEFAULT_ALLOW_LEADING_WILDCARD);
}
 
Example 20
Source File: NettyTransport.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Inject
public NettyTransport(Settings settings, ThreadPool threadPool, NetworkService networkService, BigArrays bigArrays, Version version, NamedWriteableRegistry namedWriteableRegistry) {
    super(settings);
    this.threadPool = threadPool;
    this.networkService = networkService;
    this.bigArrays = bigArrays;
    this.version = version;

    if (settings.getAsBoolean("netty.epollBugWorkaround", false)) {
        System.setProperty("org.jboss.netty.epollBugWorkaround", "true");
    }

    this.workerCount = settings.getAsInt(WORKER_COUNT, EsExecutors.boundedNumberOfProcessors(settings) * 2);
    this.blockingClient = settings.getAsBoolean("transport.netty.transport.tcp.blocking_client", settings.getAsBoolean(TCP_BLOCKING_CLIENT, settings.getAsBoolean(TCP_BLOCKING, false)));
    this.connectTimeout = this.settings.getAsTime("transport.netty.connect_timeout", settings.getAsTime("transport.tcp.connect_timeout", settings.getAsTime(TCP_CONNECT_TIMEOUT, TCP_DEFAULT_CONNECT_TIMEOUT)));
    this.maxCumulationBufferCapacity = this.settings.getAsBytesSize("transport.netty.max_cumulation_buffer_capacity", null);
    this.maxCompositeBufferComponents = this.settings.getAsInt("transport.netty.max_composite_buffer_components", -1);
    this.compress = settings.getAsBoolean(TransportSettings.TRANSPORT_TCP_COMPRESS, false);

    this.connectionsPerNodeRecovery = this.settings.getAsInt("transport.netty.connections_per_node.recovery", settings.getAsInt(CONNECTIONS_PER_NODE_RECOVERY, 2));
    this.connectionsPerNodeBulk = this.settings.getAsInt("transport.netty.connections_per_node.bulk", settings.getAsInt(CONNECTIONS_PER_NODE_BULK, 3));
    this.connectionsPerNodeReg = this.settings.getAsInt("transport.netty.connections_per_node.reg", settings.getAsInt(CONNECTIONS_PER_NODE_REG, 6));
    this.connectionsPerNodeState = this.settings.getAsInt("transport.netty.connections_per_node.high", settings.getAsInt(CONNECTIONS_PER_NODE_STATE, 1));
    this.connectionsPerNodePing = this.settings.getAsInt("transport.netty.connections_per_node.ping", settings.getAsInt(CONNECTIONS_PER_NODE_PING, 1));

    // we want to have at least 1 for reg/state/ping
    if (this.connectionsPerNodeReg == 0) {
        throw new IllegalArgumentException("can't set [connection_per_node.reg] to 0");
    }
    if (this.connectionsPerNodePing == 0) {
        throw new IllegalArgumentException("can't set [connection_per_node.ping] to 0");
    }
    if (this.connectionsPerNodeState == 0) {
        throw new IllegalArgumentException("can't set [connection_per_node.state] to 0");
    }

    long defaultReceiverPredictor = 512 * 1024;
    if (JvmInfo.jvmInfo().getMem().getDirectMemoryMax().bytes() > 0) {
        // we can guess a better default...
        long l = (long) ((0.3 * JvmInfo.jvmInfo().getMem().getDirectMemoryMax().bytes()) / workerCount);
        defaultReceiverPredictor = Math.min(defaultReceiverPredictor, Math.max(l, 64 * 1024));
    }

    // See AdaptiveReceiveBufferSizePredictor#DEFAULT_XXX for default values in netty..., we can use higher ones for us, even fixed one
    this.receivePredictorMin = this.settings.getAsBytesSize("transport.netty.receive_predictor_min", this.settings.getAsBytesSize("transport.netty.receive_predictor_size", new ByteSizeValue(defaultReceiverPredictor)));
    this.receivePredictorMax = this.settings.getAsBytesSize("transport.netty.receive_predictor_max", this.settings.getAsBytesSize("transport.netty.receive_predictor_size", new ByteSizeValue(defaultReceiverPredictor)));
    if (receivePredictorMax.bytes() == receivePredictorMin.bytes()) {
        receiveBufferSizePredictorFactory = new FixedReceiveBufferSizePredictorFactory((int) receivePredictorMax.bytes());
    } else {
        receiveBufferSizePredictorFactory = new AdaptiveReceiveBufferSizePredictorFactory((int) receivePredictorMin.bytes(), (int) receivePredictorMin.bytes(), (int) receivePredictorMax.bytes());
    }

    this.scheduledPing = new ScheduledPing();
    this.pingSchedule = settings.getAsTime(PING_SCHEDULE, DEFAULT_PING_SCHEDULE);
    if (pingSchedule.millis() > 0) {
        threadPool.schedule(pingSchedule, ThreadPool.Names.GENERIC, scheduledPing);
    }
    this.namedWriteableRegistry = namedWriteableRegistry;
}