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


Java DocumentMapperParser.checkNoRemainingFields方法代码示例

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


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

示例1: load

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入方法依赖的package包/类
private static ContextMapping load(Map<String, Object> contextConfig, Version indexVersionCreated) {
    String name = extractRequiredValue(contextConfig, FIELD_NAME);
    String type = extractRequiredValue(contextConfig, FIELD_TYPE);
    final ContextMapping contextMapping;
    switch (Type.fromString(type)) {
        case CATEGORY:
            contextMapping = CategoryContextMapping.load(name, contextConfig);
            break;
        case GEO:
            contextMapping = GeoContextMapping.load(name, contextConfig);
            break;
        default:
            throw new ElasticsearchParseException("unknown context type[" + type + "]");
    }
    DocumentMapperParser.checkNoRemainingFields(name, contextConfig, indexVersionCreated);
    return contextMapping;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:ContextMappings.java

示例2: loadMapping

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入方法依赖的package包/类
protected static ContextMapping loadMapping(String name, Map<String, Object> config, Version indexVersionCreated)
        throws ElasticsearchParseException {
    final Object argType = config.get(ContextMapping.FIELD_TYPE);

    if (argType == null) {
        throw new ElasticsearchParseException("missing [{}] in context mapping", ContextMapping.FIELD_TYPE);
    }

    final String type = argType.toString();
    ContextMapping contextMapping;
    if (GeolocationContextMapping.TYPE.equals(type)) {
        contextMapping = GeolocationContextMapping.load(name, config);
    } else if (CategoryContextMapping.TYPE.equals(type)) {
        contextMapping = CategoryContextMapping.load(name, config);
    } else {
        throw new ElasticsearchParseException("unknown context type [{}]", type);
    }
    config.remove(ContextMapping.FIELD_TYPE);
    DocumentMapperParser.checkNoRemainingFields(name, config, indexVersionCreated);

    return contextMapping;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:ContextBuilder.java

示例3: parseProperties

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入方法依赖的package包/类
protected static void parseProperties(ObjectMapper.Builder objBuilder, Map<String, Object> propsNode, ParserContext parserContext) {
    Iterator<Map.Entry<String, Object>> iterator = propsNode.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = entry.getKey();
        if (fieldName.contains(".")) {
            throw new MapperParsingException("Field name [" + fieldName + "] cannot contain '.'");
        }
        // Should accept empty arrays, as a work around for when the
        // user can't provide an empty Map. (PHP for example)
        boolean isEmptyList = entry.getValue() instanceof List && ((List<?>) entry.getValue()).isEmpty();

        if (entry.getValue() instanceof Map) {
            @SuppressWarnings("unchecked")
            Map<String, Object> propNode = (Map<String, Object>) entry.getValue();

            /* mark delete field when reindex */
            Object deleteNode = propNode.get("delete");
            if (deleteNode != null && deleteNode.toString().equals("true")) {
                /* TODO GaoPan: mark delete field when reindex */
                iterator.remove();
            } else {
                String type;
                Object typeNode = propNode.get("type");
                if (typeNode != null) {
                    type = typeNode.toString();
                } else {
                    // lets see if we can derive this...
                    if (propNode.get("properties") != null) {
                        type = ObjectMapper.CONTENT_TYPE;
                    } else if (propNode.size() == 1 && propNode.get("enabled") != null) {
                        // if there is a single property with the enabled
                        // flag on it, make it an object
                        // (usually, setting enabled to false to not index
                        // any type, including core values, which
                        type = ObjectMapper.CONTENT_TYPE;
                    } else {
                        throw new MapperParsingException("No type specified for field [" + fieldName + "]");
                    }
                }

                Mapper.TypeParser typeParser = parserContext.typeParser(type);
                if (typeParser == null) {
                    throw new MapperParsingException("No handler for type [" + type + "] declared on field [" + fieldName + "]");
                }
                objBuilder.add(typeParser.parse(fieldName, propNode, parserContext));
                propNode.remove("type");
                DocumentMapperParser.checkNoRemainingFields(fieldName, propNode, parserContext.indexVersionCreated());
                iterator.remove();
            }
        } else if (isEmptyList) {
            iterator.remove();
        } else {
            throw new MapperParsingException("Expected map for property [fields] on field [" + fieldName + "] but got a "
                    + fieldName.getClass());
        }
    }

    DocumentMapperParser.checkNoRemainingFields(propsNode, parserContext.indexVersionCreated(),
            "DocType mapping definition has unsupported parameters: ");

}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:63,代码来源:ObjectMapper.java

示例4: parseMultiField

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入方法依赖的package包/类
public static boolean parseMultiField(FieldMapper.Builder builder, String name, Mapper.TypeParser.ParserContext parserContext, String propName, Object propNode) {
    parserContext = parserContext.createMultiFieldContext(parserContext);
    if (propName.equals("path") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
        builder.multiFieldPathType(parsePathType(name, propNode.toString()));
        return true;
    } else if (propName.equals("fields")) {

        final Map<String, Object> multiFieldsPropNodes;

        if (propNode instanceof List && ((List<?>) propNode).isEmpty()) {
            multiFieldsPropNodes = Collections.emptyMap();
        } else if (propNode instanceof Map) {
            multiFieldsPropNodes = (Map<String, Object>) propNode;
        } else {
            throw new MapperParsingException("expected map for property [fields] on field [" + propNode + "] or " +
                    "[" + propName + "] but got a " + propNode.getClass());
        }

        for (Map.Entry<String, Object> multiFieldEntry : multiFieldsPropNodes.entrySet()) {
            String multiFieldName = multiFieldEntry.getKey();
            if (multiFieldName.contains(".")) {
                throw new MapperParsingException("Field name [" + multiFieldName + "] which is a multi field of [" + name + "] cannot contain '.'");
            }
            if (!(multiFieldEntry.getValue() instanceof Map)) {
                throw new MapperParsingException("illegal field [" + multiFieldName + "], only fields can be specified inside fields");
            }
            @SuppressWarnings("unchecked")
            Map<String, Object> multiFieldNodes = (Map<String, Object>) multiFieldEntry.getValue();

            String type;
            Object typeNode = multiFieldNodes.get("type");
            if (typeNode != null) {
                type = typeNode.toString();
            } else {
                throw new MapperParsingException("no type specified for property [" + multiFieldName + "]");
            }
            if (type.equals(ObjectMapper.CONTENT_TYPE) || type.equals(ObjectMapper.NESTED_CONTENT_TYPE)) {
                throw new MapperParsingException("Type [" + type + "] cannot be used in multi field");
            }

            Mapper.TypeParser typeParser = parserContext.typeParser(type);
            if (typeParser == null) {
                throw new MapperParsingException("no handler for type [" + type + "] declared on field [" + multiFieldName + "]");
            }
            builder.addMultiField(typeParser.parse(multiFieldName, multiFieldNodes, parserContext));
            multiFieldNodes.remove("type");
            DocumentMapperParser.checkNoRemainingFields(propName, multiFieldNodes, parserContext.indexVersionCreated());
        }
        return true;
    }
    return false;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:53,代码来源:TypeParsers.java

示例5: parse

import org.elasticsearch.index.mapper.DocumentMapperParser; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(final String fieldName, final Map<String, Object> node, final ParserContext parserContext) throws MapperParsingException {
    final LangStringFieldMapper.Builder builder = new LangStringFieldMapper.Builder(fieldName);
    builder.fieldType().setIndexAnalyzer(parserContext.getIndexAnalyzers().getDefaultIndexAnalyzer());
    builder.fieldType().setSearchAnalyzer(parserContext.getIndexAnalyzers().getDefaultSearchAnalyzer());
    builder.fieldType().setSearchQuoteAnalyzer(parserContext.getIndexAnalyzers().getDefaultSearchQuoteAnalyzer());
    parseTextField(builder, fieldName, node, parserContext);
    for (final Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        final Map.Entry<String, Object> entry = iterator.next();
        final String propName = entry.getKey();
        final Object propNode = entry.getValue();
        if (propName.equals("position_increment_gap")) {
            final int newPositionIncrementGap = XContentMapValues.nodeIntegerValue(propNode, -1);
            builder.positionIncrementGap(newPositionIncrementGap);
            iterator.remove();
        } else if (propName.equals("fielddata")) {
            builder.fielddata(XContentMapValues.nodeBooleanValue(propNode, "fielddata"));
            iterator.remove();
        } else if (propName.equals("eager_global_ordinals")) {
            builder.eagerGlobalOrdinals(XContentMapValues.nodeBooleanValue(propNode, "eager_global_ordinals"));
            iterator.remove();
        } else if (propName.equals("fielddata_frequency_filter")) {
            final Map<?,?> frequencyFilter = (Map<?, ?>) propNode;
            final double minFrequency = XContentMapValues.nodeDoubleValue(frequencyFilter.remove("min"), 0);
            final double maxFrequency = XContentMapValues.nodeDoubleValue(frequencyFilter.remove("max"), Integer.MAX_VALUE);
            final int minSegmentSize = XContentMapValues.nodeIntegerValue(frequencyFilter.remove("min_segment_size"), 0);
            builder.fielddataFrequencyFilter(minFrequency, maxFrequency, minSegmentSize);
            DocumentMapperParser.checkNoRemainingFields(propName, frequencyFilter, parserContext.indexVersionCreated());
            iterator.remove();
        } else if (propName.equals(SEPARATOR_SETTING_KEY)) {
            builder.fieldSeparator(propNode.toString());
            iterator.remove();
        } else if (propName.equals(LANG_SETTING_KEY)) {
            builder.supportedLanguages(
                    XContentMapValues.nodeStringArrayValue(propNode));
            iterator.remove();
        } else if (propName.equals(LANG_FIELD_SETTING_KEY)) {
            builder.langField(propNode.toString());
            iterator.remove();
        } else if (propName.equals(LANG_BASE_NAME_SETTING_KEY)) {
            builder.langBaseName(propNode.toString());
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:codelibs,项目名称:elasticsearch-langfield,代码行数:47,代码来源:LangStringFieldMapper.java


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