当前位置: 首页>>代码示例>>Java>>正文


Java Regex.isSimpleMatchPattern方法代码示例

本文整理汇总了Java中org.elasticsearch.common.regex.Regex.isSimpleMatchPattern方法的典型用法代码示例。如果您正苦于以下问题:Java Regex.isSimpleMatchPattern方法的具体用法?Java Regex.isSimpleMatchPattern怎么用?Java Regex.isSimpleMatchPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.regex.Regex的用法示例。


在下文中一共展示了Regex.isSimpleMatchPattern方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isPatternMatchingAllIndices

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
/**
 * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices
 *
 * @param indicesOrAliases the array containing index names
 * @param concreteIndices  array containing the concrete indices that the first argument refers to
 * @return true if the first argument is a pattern that maps to all available indices, false otherwise
 */
boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) {
    // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure
    if (concreteIndices.length == metaData.getConcreteAllIndices().length && indicesOrAliases.length > 0) {

        //we might have something like /-test1,+test1 that would identify all indices
        //or something like /-test1 with test1 index missing and IndicesOptions.lenient()
        if (indicesOrAliases[0].charAt(0) == '-') {
            return true;
        }

        //otherwise we check if there's any simple regex
        for (String indexOrAlias : indicesOrAliases) {
            if (Regex.isSimpleMatchPattern(indexOrAlias)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:IndexNameExpressionResolver.java

示例2: filterSettings

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
private static Settings filterSettings(Iterable<String> patterns, Settings settings) {
    Settings.Builder builder = Settings.builder().put(settings);
    List<String> simpleMatchPatternList = new ArrayList<>();
    for (String pattern : patterns) {
        if (Regex.isSimpleMatchPattern(pattern)) {
            simpleMatchPatternList.add(pattern);
        } else {
            builder.remove(pattern);
        }
    }
    if (!simpleMatchPatternList.isEmpty()) {
        String[] simpleMatchPatterns = simpleMatchPatternList.toArray(new String[simpleMatchPatternList.size()]);
        Iterator<Entry<String, String>> iterator = builder.internalMap().entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> current = iterator.next();
            if (Regex.simpleMatch(simpleMatchPatterns, current.getKey())) {
                iterator.remove();
            }
        }
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:SettingsFilter.java

示例3: masterOperation

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
@Override
protected void masterOperation(GetIndexTemplatesRequest request, ClusterState state, ActionListener<GetIndexTemplatesResponse> listener) {
    List<IndexTemplateMetaData> results;

    // If we did not ask for a specific name, then we return all templates
    if (request.names().length == 0) {
        results = Arrays.asList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class));
    } else {
        results = new ArrayList<>();
    }

    for (String name : request.names()) {
        if (Regex.isSimpleMatchPattern(name)) {
            for (ObjectObjectCursor<String, IndexTemplateMetaData> entry : state.metaData().templates()) {
                if (Regex.simpleMatch(name, entry.key)) {
                    results.add(entry.value);
                }
            }
        } else if (state.metaData().templates().containsKey(name)) {
            results.add(state.metaData().templates().get(name));
        }
    }

    listener.onResponse(new GetIndexTemplatesResponse(results));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TransportGetIndexTemplatesAction.java

示例4: extractFieldAndBoost

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
private void extractFieldAndBoost(QueryParseContext parseContext, XContentParser parser, Map<String, Float> fieldNameWithBoosts) throws IOException {
    String fField = null;
    Float fBoost = null;
    char[] fieldText = parser.textCharacters();
    int end = parser.textOffset() + parser.textLength();
    for (int i = parser.textOffset(); i < end; i++) {
        if (fieldText[i] == '^') {
            int relativeLocation = i - parser.textOffset();
            fField = new String(fieldText, parser.textOffset(), relativeLocation);
            fBoost = Float.parseFloat(new String(fieldText, i + 1, parser.textLength() - relativeLocation - 1));
            break;
        }
    }
    if (fField == null) {
        fField = parser.text();
    }

    if (Regex.isSimpleMatchPattern(fField)) {
        for (String field : parseContext.mapperService().simpleMatchToIndexNames(fField)) {
            fieldNameWithBoosts.put(field, fBoost);
        }
    } else {
        fieldNameWithBoosts.put(fField, fBoost);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:MultiMatchQueryParser.java

示例5: isPatternMatchingAllIndices

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
/**
 * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices
 *
 * @param indicesOrAliases the array containing index names
 * @param concreteIndices  array containing the concrete indices that the first argument refers to
 * @return true if the first argument is a pattern that maps to all available indices, false otherwise
 */
boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) {
    // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure
    if (concreteIndices.length == metaData.concreteAllIndices().length && indicesOrAliases.length > 0) {

        //we might have something like /-test1,+test1 that would identify all indices
        //or something like /-test1 with test1 index missing and IndicesOptions.lenient()
        if (indicesOrAliases[0].charAt(0) == '-') {
            return true;
        }

        //otherwise we check if there's any simple regex
        for (String indexOrAlias : indicesOrAliases) {
            if (Regex.isSimpleMatchPattern(indexOrAlias)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:IndexNameExpressionResolver.java

示例6: filterSettings

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
public static Settings filterSettings(String patterns, Settings settings) {
    String[] patternArray = Strings.delimitedListToStringArray(patterns, ",");
    Settings.Builder builder = Settings.settingsBuilder().put(settings);
    List<String> simpleMatchPatternList = new ArrayList<>();
    for (String pattern : patternArray) {
        if (Regex.isSimpleMatchPattern(pattern)) {
            simpleMatchPatternList.add(pattern);
        } else {
            builder.remove(pattern);
        }
    }
    if (!simpleMatchPatternList.isEmpty()) {
        String[] simpleMatchPatterns = simpleMatchPatternList.toArray(new String[simpleMatchPatternList.size()]);
        Iterator<Entry<String, String>> iterator = builder.internalMap().entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> current = iterator.next();
            if (Regex.simpleMatch(simpleMatchPatterns, current.getKey())) {
                iterator.remove();
            }
        }
    }
    return builder.build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:SettingsFilter.java

示例7: innerGetPipelines

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
List<PipelineConfiguration> innerGetPipelines(IngestMetadata ingestMetadata, String... ids) {
    if (ingestMetadata == null) {
        return Collections.emptyList();
    }

    // if we didn't ask for _any_ ID, then we get them all (this is the same as if they ask for '*')
    if (ids.length == 0) {
        return new ArrayList<>(ingestMetadata.getPipelines().values());
    }

    List<PipelineConfiguration> result = new ArrayList<>(ids.length);
    for (String id : ids) {
        if (Regex.isSimpleMatchPattern(id)) {
            for (Map.Entry<String, PipelineConfiguration> entry : ingestMetadata.getPipelines().entrySet()) {
                if (Regex.simpleMatch(id, entry.getKey())) {
                    result.add(entry.getValue());
                }
            }
        } else {
            PipelineConfiguration pipeline = ingestMetadata.getPipelines().get(id);
            if (pipeline != null) {
                result.add(pipeline);
            }
        }
    }
    return result;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:PipelineStore.java

示例8: handleFieldsMatchPattern

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
private static Map<String, Float> handleFieldsMatchPattern(MapperService mapperService, Map<String, Float> fieldsBoosts) {
    Map<String, Float> newFieldsBoosts = new TreeMap<>();
    for (Map.Entry<String, Float> fieldBoost : fieldsBoosts.entrySet()) {
        String fField = fieldBoost.getKey();
        Float fBoost = fieldBoost.getValue();
        if (Regex.isSimpleMatchPattern(fField)) {
            for (String field : mapperService.simpleMatchToIndexNames(fField)) {
                newFieldsBoosts.put(field, fBoost);
            }
        } else {
            newFieldsBoosts.put(fField, fBoost);
        }
    }
    return newFieldsBoosts;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:MultiMatchQueryBuilder.java

示例9: simpleMatchToIndexNames

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
/**
 * Returns all the fields that match the given pattern. If the pattern is prefixed with a type
 * then the fields will be returned with a type prefix.
 */
public Collection<String> simpleMatchToIndexNames(String pattern) {
    if (Regex.isSimpleMatchPattern(pattern) == false) {
        // no wildcards
        return Collections.singletonList(pattern);
    }
    return fieldTypes.simpleMatchToFullName(pattern);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:MapperService.java

示例10: expandHeadersFromRequest

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
/**
 * Extracts all the required fields from the RestRequest 'h' parameter. In order to support wildcards like
 * 'bulk.*' this needs potentially parse all the configured headers and its aliases and needs to ensure
 * that everything is only added once to the returned headers, even if 'h=bulk.*.bulk.*' is specified
 * or some headers are contained twice due to matching aliases
 */
private static Set<String> expandHeadersFromRequest(Table table, RestRequest request) {
    Set<String> headers = new LinkedHashSet<>(table.getHeaders().size());

    // check headers and aliases
    for (String header : Strings.splitStringByCommaToArray(request.param("h"))) {
        if (Regex.isSimpleMatchPattern(header)) {
            for (Table.Cell tableHeaderCell : table.getHeaders()) {
                String configuredHeader = tableHeaderCell.value.toString();
                if (Regex.simpleMatch(header, configuredHeader)) {
                    headers.add(configuredHeader);
                } else if (tableHeaderCell.attr.containsKey("alias")) {
                    String[] aliases = Strings.splitStringByCommaToArray(tableHeaderCell.attr.get("alias"));
                    for (String alias : aliases) {
                        if (Regex.simpleMatch(header, alias)) {
                            headers.add(configuredHeader);
                            break;
                        }
                    }
                }
            }
        } else {
            headers.add(header);
        }
    }

    return headers;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:RestTable.java

示例11: match

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
@Override
public void match(LogEvent event) {
    if (event.getLevel().equals(level) && event.getLoggerName().equals(logger)) {
        if (Regex.isSimpleMatchPattern(message)) {
            if (Regex.simpleMatch(message, event.getMessage().getFormattedMessage())) {
                saw = true;
            }
        } else {
            if (event.getMessage().toString().contains(message)) {
                saw = true;
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:MockLogAppender.java

示例12: simpleMatchToIndexNames

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
/**
 * Returns all the fields that match the given pattern. If the pattern is prefixed with a type
 * then the fields will be returned with a type prefix.
 */
public Collection<String> simpleMatchToIndexNames(String pattern) {
    if (Regex.isSimpleMatchPattern(pattern) == false) {
        // no wildcards
        return Collections.singletonList(pattern);
    }
    return fieldTypes.simpleMatchToIndexNames(pattern);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:MapperService.java

示例13: doToQuery

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
    // field names in builder can have wildcards etc, need to resolve them here
    Map<String, Float> resolvedFieldsAndWeights = new TreeMap<>();

    if ((useAllFields != null && useAllFields) && (fieldsAndWeights.size() != 0)) {
        throw addValidationError("cannot use [all_fields] parameter in conjunction with [fields]", null);
    }

    // If explicitly required to use all fields, use all fields, OR:
    // Automatically determine the fields (to replace the _all field) if all of the following are true:
    // - The _all field is disabled,
    // - and the default_field has not been changed in the settings
    // - and no fields are specified in the request
    Settings newSettings = new Settings(settings);
    if ((this.useAllFields != null && this.useAllFields) ||
            (context.getMapperService().allEnabled() == false &&
                    "_all".equals(context.defaultField()) &&
                    this.fieldsAndWeights.isEmpty())) {
        resolvedFieldsAndWeights = QueryStringQueryBuilder.allQueryableDefaultFields(context);
        // Need to use lenient mode when using "all-mode" so exceptions aren't thrown due to mismatched types
        newSettings.lenient(lenientSet ? settings.lenient() : true);
    } else {
        // Use the default field if no fields specified
        if (fieldsAndWeights.isEmpty()) {
            resolvedFieldsAndWeights.put(resolveIndexName(context.defaultField(), context), AbstractQueryBuilder.DEFAULT_BOOST);
        } else {
            for (Map.Entry<String, Float> fieldEntry : fieldsAndWeights.entrySet()) {
                if (Regex.isSimpleMatchPattern(fieldEntry.getKey())) {
                    for (String fieldName : context.getMapperService().simpleMatchToIndexNames(fieldEntry.getKey())) {
                        resolvedFieldsAndWeights.put(fieldName, fieldEntry.getValue());
                    }
                } else {
                    resolvedFieldsAndWeights.put(resolveIndexName(fieldEntry.getKey(), context), fieldEntry.getValue());
                }
            }
        }
    }

    // Use standard analyzer by default if none specified
    Analyzer luceneAnalyzer;
    if (analyzer == null) {
        luceneAnalyzer = context.getMapperService().searchAnalyzer();
    } else {
        luceneAnalyzer = context.getIndexAnalyzers().get(analyzer);
        if (luceneAnalyzer == null) {
            throw new QueryShardException(context, "[" + SimpleQueryStringBuilder.NAME + "] analyzer [" + analyzer
                    + "] not found");
        }

    }

    SimpleQueryParser sqp = new SimpleQueryParser(luceneAnalyzer, resolvedFieldsAndWeights, flags, newSettings, context);
    sqp.setDefaultOperator(defaultOperator.toBooleanClauseOccur());
    Query query = sqp.parse(queryText);
    return Queries.maybeApplyMinimumShouldMatch(query, minimumShouldMatch);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:58,代码来源:SimpleQueryStringBuilder.java

示例14: isValidPattern

import org.elasticsearch.common.regex.Regex; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> iff the given string is either a valid settings key pattern or a simple regular expression
 * @see Regex
 * @see AbstractScopedSettings#isValidKey(String)
 */
public static boolean isValidPattern(String pattern) {
    return AbstractScopedSettings.isValidKey(pattern) || Regex.isSimpleMatchPattern(pattern);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:SettingsFilter.java


注:本文中的org.elasticsearch.common.regex.Regex.isSimpleMatchPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。