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


Java Strings.toUnderscoreCase方法代码示例

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


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

示例1: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    if (parserContext.indexVersionCreated().before(Version.V_1_3_0)) {
        throw new IllegalArgumentException("type="+CONTENT_TYPE+" is not supported on indices created before version 1.3.0. Is your cluster running multiple datanode versions?");
    }
    
    Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
    if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
        parseField(builder, builder.name, node, parserContext);
    }

    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (fieldName.equals("enabled")) {
            builder.enabled(nodeBooleanValue(fieldNode));
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:FieldNamesFieldMapper.java

示例2: parseNumberField

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public static void parseNumberField(NumberFieldMapper.Builder builder, String name, Map<String, Object> numberNode, Mapper.TypeParser.ParserContext parserContext) {
    parseField(builder, name, numberNode, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = numberNode.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String propName = Strings.toUnderscoreCase(entry.getKey());
        Object propNode = entry.getValue();
        if (propName.equals("precision_step")) {
            builder.precisionStep(nodeIntegerValue(propNode));
            iterator.remove();
        } else if (propName.equals("ignore_malformed")) {
            builder.ignoreMalformed(nodeBooleanValue(propNode));
            iterator.remove();
        } else if (propName.equals("coerce")) {
            builder.coerce(nodeBooleanValue(propNode));
            iterator.remove();
        } else if (propName.equals("omit_norms")) {
            builder.omitNorms(nodeBooleanValue(propNode));
            iterator.remove();
        } else if (propName.equals("similarity")) {
            builder.similarity(parserContext.similarityLookupService().similarity(propNode.toString()));
            iterator.remove();
        } else if (parseMultiField(builder, name, parserContext, propName, propNode)) {
            iterator.remove();
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:27,代码来源:TypeParsers.java

示例3: visitCreateAnalyzer

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public CreateAnalyzerAnalyzedStatement visitCreateAnalyzer(CreateAnalyzer node, Context context) {
    String underscoreIdent = Strings.toUnderscoreCase(node.ident());
    if (!underscoreIdent.equalsIgnoreCase(node.ident())) {
        deprecationLogger.deprecated("Deprecated analyzer name [{}], use [{}] instead", node.ident(), underscoreIdent);
    }

    context.statement = new CreateAnalyzerAnalyzedStatement(fulltextAnalyzerResolver);
    context.statement.ident(node.ident());

    if (node.isExtending()) {
        context.statement.extendedAnalyzer(node.extendedAnalyzer().get());
    }

    for (AnalyzerElement element : node.elements()) {
        process(element, context);
    }

    return context.statement;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:CreateAnalyzerStatementAnalyzer.java

示例4: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    Builder builder = new Builder(parserContext.type());
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (fieldName.equals("type")) {
            builder.type(fieldNode.toString());
            iterator.remove();
        } else if (fieldName.equals("postings_format") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
            // ignore before 2.0, reject on and after 2.0
            iterator.remove();
        } else if (fieldName.equals("fielddata")) {
            // Only take over `loading`, since that is the only option now that is configurable:
            Map<String, String> fieldDataSettings = SettingsLoader.Helper.loadNestedFromMap(nodeMapValue(fieldNode, "fielddata"));
            if (fieldDataSettings.containsKey(MappedFieldType.Loading.KEY)) {
                Settings settings = settingsBuilder().put(MappedFieldType.Loading.KEY, fieldDataSettings.get(MappedFieldType.Loading.KEY)).build();
                builder.fieldDataSettings(settings);
            }
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:ParentFieldMapper.java

示例5: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    FloatFieldMapper.Builder builder = floatField(name);
    parseNumberField(builder, name, node, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String propName = Strings.toUnderscoreCase(entry.getKey());
        Object propNode = entry.getValue();
        if (propName.equals("null_value")) {
            if (propNode == null) {
                throw new MapperParsingException("Property [null_value] cannot be null.");
            }
            builder.nullValue(nodeFloatValue(propNode));
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:FloatFieldMapper.java

示例6: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    LongFieldMapper.Builder builder = longField(name);
    parseNumberField(builder, name, node, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String propName = Strings.toUnderscoreCase(entry.getKey());
        Object propNode = entry.getValue();
        if (propName.equals("null_value")) {
            if (propNode == null) {
                throw new MapperParsingException("Property [null_value] cannot be null.");
            }
            builder.nullValue(nodeLongValue(propNode));
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:LongFieldMapper.java

示例7: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    if (parserContext.indexVersionCreated().onOrAfter(Version.V_2_0_0_beta1)) {
        throw new MapperParsingException(NAME + " is not configurable");
    }
    Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
    parseField(builder, builder.name, node, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (fieldName.equals("path")) {
            builder.path(fieldNode.toString());
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:IdFieldMapper.java

示例8: parsePathType

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public static ContentPath.Type parsePathType(String name, String path) throws MapperParsingException {
    path = Strings.toUnderscoreCase(path);
    if ("just_name".equals(path)) {
        return ContentPath.Type.JUST_NAME;
    } else if ("full".equals(path)) {
        return ContentPath.Type.FULL;
    } else {
        throw new MapperParsingException("wrong value for pathType [" + path + "] for object [" + name + "]");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:TypeParsers.java

示例9: getExceptionName

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
/**
 * Returns a underscore case name for the given exception. This method strips <tt>Elasticsearch</tt> prefixes from exception names.
 */
public static String getExceptionName(Throwable ex) {
    String simpleName = ex.getClass().getSimpleName();
    if (simpleName.startsWith("Elasticsearch")) {
        simpleName = simpleName.substring("Elasticsearch".length());
    }
    return Strings.toUnderscoreCase(simpleName);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ElasticsearchException.java

示例10: tokenizer

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public TokenizerFactory tokenizer(String name) {
    TokenizerFactory tokenizerFactory = tokenizers.get(name);
    if (tokenizerFactory != null) {
        return tokenizerFactory;
    }
    String underscoreName = Strings.toUnderscoreCase(name);
    tokenizerFactory = tokenizers.get(underscoreName);
    if (tokenizerFactory != null) {
        DEPRECATION_LOGGER.deprecated("Deprecated tokenizer name [" + name + "], use [" + underscoreName + "] instead");
    }
    return tokenizerFactory;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:AnalysisService.java

示例11: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    ObjectMapper.Builder builder = createBuilder(name);
    parseNested(name, node, builder);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (parseObjectOrDocumentTypeProperties(fieldName, fieldNode, parserContext, builder) || parseObjectProperties(name, fieldName,  fieldNode, parserContext, builder)) {
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:ObjectMapper.java

示例12: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public static DynamicTemplate parse(String name, Map<String, Object> conf) throws MapperParsingException {
    String match = null;
    String pathMatch = null;
    String unmatch = null;
    String pathUnmatch = null;
    Map<String, Object> mapping = null;
    String matchMappingType = null;
    String matchPattern = "simple";

    for (Map.Entry<String, Object> entry : conf.entrySet()) {
        String propName = Strings.toUnderscoreCase(entry.getKey());
        if ("match".equals(propName)) {
            match = entry.getValue().toString();
        } else if ("path_match".equals(propName)) {
            pathMatch = entry.getValue().toString();
        } else if ("unmatch".equals(propName)) {
            unmatch = entry.getValue().toString();
        } else if ("path_unmatch".equals(propName)) {
            pathUnmatch = entry.getValue().toString();
        } else if ("match_mapping_type".equals(propName)) {
            matchMappingType = entry.getValue().toString();
        } else if ("match_pattern".equals(propName)) {
            matchPattern = entry.getValue().toString();
        } else if ("mapping".equals(propName)) {
            mapping = (Map<String, Object>) entry.getValue();
        }
    }

    if (match == null && pathMatch == null && matchMappingType == null) {
        throw new MapperParsingException("template must have match, path_match or match_mapping_type set");
    }
    if (mapping == null) {
        throw new MapperParsingException("template must have mapping set");
    }
    return new DynamicTemplate(name, conf, pathMatch, pathUnmatch, match, unmatch, matchMappingType, MatchType.fromString(matchPattern), mapping);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:DynamicTemplate.java

示例13: parse

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
    
    // parseField below will happily parse the doc_values setting, but it is then never passed to
    // the AllFieldMapper ctor in the builder since it is not valid. Here we validate
    // the doc values settings (old and new) are rejected
    Object docValues = node.get("doc_values");
    if (docValues != null && nodeBooleanValue(docValues)) {
        throw new MapperParsingException("Field [" + name + "] is always tokenized and cannot have doc values");
    }
    // convoluted way of specifying doc values
    Object fielddata = node.get("fielddata");
    if (fielddata != null) {
        Map<String, Object> fielddataMap = nodeMapValue(fielddata, "fielddata");
        Object format = fielddataMap.get("format");
        if ("doc_values".equals(format)) {
            throw new MapperParsingException("Field [" + name + "] is always tokenized and cannot have doc values");
        }
    }
    
    parseTextField(builder, builder.name, node, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (fieldName.equals("enabled")) {
            builder.enabled(nodeBooleanValue(fieldNode) ? EnabledAttributeMapper.ENABLED : EnabledAttributeMapper.DISABLED);
            iterator.remove();
        } else if (fieldName.equals("auto_boost") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
            // Old 1.x setting which is now ignored
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:AllFieldMapper.java

示例14: parseIndex

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public static void parseIndex(String fieldName, String index, FieldMapper.Builder builder) throws MapperParsingException {
    index = Strings.toUnderscoreCase(index);
    if ("no".equals(index)) {
        builder.index(false);
    } else if ("not_analyzed".equals(index)) {
        builder.index(true);
        builder.tokenized(false);
    } else if ("analyzed".equals(index)) {
        builder.index(true);
        builder.tokenized(true);
    } else {
        throw new MapperParsingException("wrong value for index [" + index + "] for field [" + fieldName + "]");
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:TypeParsers.java

示例15: visitTokenizer

import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public CreateAnalyzerAnalyzedStatement visitTokenizer(Tokenizer tokenizer, Context context) {
    String name = tokenizer.ident();
    Optional<io.crate.sql.tree.GenericProperties> properties = tokenizer.properties();

    String underscoreName = Strings.toUnderscoreCase(name);
    if (!underscoreName.equalsIgnoreCase(name)) {
        deprecationLogger.deprecated("Deprecated tokenizer name [{}], use [{}] instead", name, underscoreName);
    }

    if (!properties.isPresent()) {
        // use a builtin tokenizer without parameters

        // validate
        if (!context.statement.analyzerService().hasBuiltInTokenizer(name)) {
            throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Non-existing tokenizer '%s'", name));
        }
        // build
        context.statement.tokenDefinition(name, Settings.EMPTY);
    } else {
        // validate
        if (!context.statement.analyzerService().hasBuiltInTokenizer(name)) {
            // type mandatory
            String evaluatedType = extractType(properties.get(), context.analysis.parameterContext());
            if (!context.statement.analyzerService().hasBuiltInTokenizer(evaluatedType)) {
                // only builtin tokenizers can be extended, for now
                throw new IllegalArgumentException(String.format(Locale.ENGLISH,
                    "Non-existing built-in tokenizer type '%s'", evaluatedType));
            }
        } else {
            throw new IllegalArgumentException(String.format(Locale.ENGLISH, "tokenizer name '%s' is reserved", name));
        }
        // build
        // transform name as tokenizer is not publicly available
        name = String.format(Locale.ENGLISH, "%s_%s", context.statement.ident(), name);

        Settings.Builder builder = Settings.builder();
        for (Map.Entry<String, Expression> tokenizerProperty : properties.get().properties().entrySet()) {
            GenericPropertiesConverter.genericPropertyToSetting(builder,
                context.statement.getSettingsKey("index.analysis.tokenizer.%s.%s", name, tokenizerProperty.getKey()),
                tokenizerProperty.getValue(),
                context.analysis.parameterContext());
        }
        context.statement.tokenDefinition(name, builder.build());
    }

    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:49,代码来源:CreateAnalyzerStatementAnalyzer.java


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