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


Java XContentParser.currentName方法代码示例

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


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

示例1: parse

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static TeardownSection parse(XContentParser parser) throws IOException {
    TeardownSection teardownSection = new TeardownSection();
    teardownSection.setSkipSection(SkipSection.parseIfNext(parser));

    while (parser.currentToken() != XContentParser.Token.END_ARRAY) {
        ParserUtils.advanceToFieldName(parser);
        if (!"do".equals(parser.currentName())) {
            throw new ParsingException(parser.getTokenLocation(),
                    "section [" + parser.currentName() + "] not supported within teardown section");
        }

        teardownSection.addDoSection(DoSection.parse(parser));
        parser.nextToken();
    }

    parser.nextToken();
    return teardownSection;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:TeardownSection.java

示例2: innerParseObject

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
private static void innerParseObject(ParseContext context, ObjectMapper mapper, XContentParser parser, String currentFieldName, XContentParser.Token token) throws IOException {
    while (token != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.START_OBJECT) {
            parseObject(context, mapper, currentFieldName);
        } else if (token == XContentParser.Token.START_ARRAY) {
            parseArray(context, mapper, currentFieldName);
        } else if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
            if (MapperService.isMetadataField(context.path().pathAsText(currentFieldName))) {
                throw new MapperParsingException("Field [" + currentFieldName + "] is a metadata field and cannot be added inside a document. Use the index API request parameters.");
            }
        } else if (token == XContentParser.Token.VALUE_NULL) {
            parseNullValue(context, mapper, currentFieldName);
        } else if (token == null) {
            throw new MapperParsingException("object mapping for [" + mapper.name() + "] tried to parse field [" + currentFieldName + "] as object, but got EOF, has a concrete value been provided to it?");
        } else if (token.isValue()) {
            parseValue(context, mapper, currentFieldName, token);
        }
        token = parser.nextToken();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:DocumentParser.java

示例3: parse

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
@Override
public AggregatorFactory parse(String aggregationName, XContentParser parser, SearchContext context) throws IOException {

    ValuesSourceParser vsParser = ValuesSourceParser.any(aggregationName, InternalMissing.TYPE, context)
            .scriptable(false)
            .build();

    XContentParser.Token token;
    String currentFieldName = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (vsParser.token(currentFieldName, token, parser)) {
            continue;
        } else {
            throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].",
                    parser.getTokenLocation());
        }
    }

    return new MissingAggregator.Factory(aggregationName, vsParser.config());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:MissingParser.java

示例4: parse

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public InnerHitsSubSearchContext parse(QueryParseContext parserContext) throws IOException, QueryParsingException {
    String fieldName = null;
    XContentParser.Token token;
    String innerHitName = null;
    SubSearchContext subSearchContext = new SubSearchContext(SearchContext.current());
    try {
        XContentParser parser = parserContext.parser();
        while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (token == XContentParser.Token.FIELD_NAME) {
                fieldName = parser.currentName();
            } else if (token.isValue()) {
                if ("name".equals(fieldName)) {
                    innerHitName = parser.textOrNull();
                } else {
                    parseCommonInnerHitOptions(parser, token, fieldName, subSearchContext, sortParseElement, sourceParseElement, highlighterParseElement, scriptFieldsParseElement, fieldDataFieldsParseElement);
                }
            } else {
                parseCommonInnerHitOptions(parser, token, fieldName, subSearchContext, sortParseElement, sourceParseElement, highlighterParseElement, scriptFieldsParseElement, fieldDataFieldsParseElement);
            }
        }
    } catch (Exception e) {
        throw new QueryParsingException(parserContext, "Failed to parse [_inner_hits]", e);
    }
    return new InnerHitsSubSearchContext(innerHitName, subSearchContext);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:InnerHitsQueryParserHelper.java

示例5: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static ScriptScoreFunctionBuilder fromXContent(QueryParseContext parseContext)
        throws IOException, ParsingException {
    XContentParser parser = parseContext.parser();
    Script script = null;
    String currentFieldName = null;
    XContentParser.Token token;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else {
            if (Script.SCRIPT_PARSE_FIELD.match(currentFieldName)) {
                script = Script.parse(parser);
            } else {
                throw new ParsingException(parser.getTokenLocation(), NAME + " query does not support [" + currentFieldName + "]");
            }
        }
    }

    if (script == null) {
        throw new ParsingException(parser.getTokenLocation(), NAME + " requires 'script' field");
    }

    return new ScriptScoreFunctionBuilder(script);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ScriptScoreFunctionBuilder.java

示例6: parse

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
@Override
public SuggestionSearchContext.SuggestionContext parse(XContentParser parser, MapperService mapperService,
        IndexQueryParserService queryParserService, HasContextAndHeaders headersContext) throws IOException {
    XContentParser.Token token;
    String fieldName = null;
    TermSuggestionContext suggestion = new TermSuggestionContext(suggester);
    DirectSpellcheckerSettings settings = suggestion.getDirectSpellCheckerSettings();
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            fieldName = parser.currentName();
        } else if (token.isValue()) {
            parseTokenValue(parser, mapperService, fieldName, suggestion, settings, queryParserService.parseFieldMatcher());
        } else {
            throw new IllegalArgumentException("suggester[term]  doesn't support field [" + fieldName + "]");
        }
    }
    return suggestion;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:TermSuggestParser.java

示例7: serializeArray

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
private void serializeArray(Map<String, String> settings, StringBuilder sb, List<String> path, XContentParser parser, String fieldName)
        throws IOException {
    XContentParser.Token token;
    int counter = 0;
    while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
        if (token == XContentParser.Token.START_OBJECT) {
            serializeObject(settings, sb, path, parser, fieldName + '.' + (counter++));
        } else if (token == XContentParser.Token.START_ARRAY) {
            serializeArray(settings, sb, path, parser, fieldName + '.' + (counter++));
        } else if (token == XContentParser.Token.FIELD_NAME) {
            fieldName = parser.currentName();
        } else if (token == XContentParser.Token.VALUE_NULL) {
            serializeValue(settings, sb, path, parser, fieldName + '.' + (counter++), true);
            // ignore
        } else {
            serializeValue(settings, sb, path, parser, fieldName + '.' + (counter++), false);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:XContentSettingsLoader.java

示例8: parseCompoundSortField

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
private static void parseCompoundSortField(QueryParseContext context, List<SortBuilder<?>> sortFields)
        throws IOException {
    XContentParser.Token token;
    XContentParser parser = context.parser();
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            String fieldName = parser.currentName();
            token = parser.nextToken();
            if (token == XContentParser.Token.VALUE_STRING) {
                SortOrder order = SortOrder.fromString(parser.text());
                sortFields.add(fieldOrScoreSort(fieldName).order(order));
            } else {
                if (PARSERS.containsKey(fieldName)) {
                    sortFields.add(PARSERS.get(fieldName).fromXContent(context, fieldName));
                } else {
                    sortFields.add(FieldSortBuilder.fromXContent(context, fieldName));
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:SortBuilder.java

示例9: parseXContentFields

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
/**
 * Parse the current token and update the parsing context appropriately.
 */
public static void parseXContentFields(XContentParser parser, Builder context) throws IOException {
    XContentParser.Token token = parser.currentToken();
    String currentFieldName = parser.currentName();

    if (FOUND.equals(currentFieldName)) {
        if (token.isValue()) {
            context.setFound(parser.booleanValue());
        }
    } else {
        DocWriteResponse.parseInnerToXContent(parser, context);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:DeleteResponse.java

示例10: parseSubArrays

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
private Object[][] parseSubArrays(SQLXContentSourceContext context, XContentParser parser) throws IOException {
    XContentParser.Token token;
    List<Object[]> list = new ArrayList<Object[]>();
    while((token = parser.nextToken()) != XContentParser.Token.END_ARRAY){
        if(token == XContentParser.Token.START_ARRAY) {
            list.add(parseSubArray(context, parser));
        } else {
            throw new SQLParseSourceException(context, "Field [" + parser.currentName() + "] has an invalid value");
        }
    }
    return list.toArray(new Object[list.size()][]);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:SQLBulkArgsParseElement.java

示例11: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static ShardSearchFailure fromXContent(XContentParser parser) throws IOException {
    XContentParser.Token token;
    ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation);
    String currentFieldName = null;
    int shardId = -1;
    String indexName = null;
    String nodeId = null;
    ElasticsearchException exception = null;
    while((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token.isValue()) {
            if (SHARD_FIELD.equals(currentFieldName)) {
                shardId  = parser.intValue();
            } else if (INDEX_FIELD.equals(currentFieldName)) {
                indexName  = parser.text();
            } else if (NODE_FIELD.equals(currentFieldName)) {
                nodeId  = parser.text();
            } else {
                throwUnknownField(currentFieldName, parser.getTokenLocation());
            }
        } else if (token == XContentParser.Token.START_OBJECT) {
            if (REASON_FIELD.equals(currentFieldName)) {
                exception = ElasticsearchException.fromXContent(parser);
            } else {
                throwUnknownField(currentFieldName, parser.getTokenLocation());
            }
        } else {
            throwUnknownToken(token, parser.getTokenLocation());
        }
    }
    return new ShardSearchFailure(exception,
            new SearchShardTarget(nodeId, new ShardId(new Index(indexName, IndexMetaData.INDEX_UUID_NA_VALUE), shardId)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:ShardSearchFailure.java

示例12: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static Range fromXContent(XContentParser parser) throws IOException {
    XContentParser.Token token;
    String currentFieldName = null;
    double from = Double.NEGATIVE_INFINITY;
    String fromAsStr = null;
    double to = Double.POSITIVE_INFINITY;
    String toAsStr = null;
    String key = null;
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token == XContentParser.Token.VALUE_NUMBER) {
            if (FROM_FIELD.match(currentFieldName)) {
                from = parser.doubleValue();
            } else if (TO_FIELD.match(currentFieldName)) {
                to = parser.doubleValue();
            }
        } else if (token == XContentParser.Token.VALUE_STRING) {
            if (FROM_FIELD.match(currentFieldName)) {
                fromAsStr = parser.text();
            } else if (TO_FIELD.match(currentFieldName)) {
                toAsStr = parser.text();
            } else if (KEY_FIELD.match(currentFieldName)) {
                key = parser.text();
            }
        }
    }
    return new Range(key, from, fromAsStr, to, toAsStr);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:RangeAggregator.java

示例13: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
public static AliasMetaData fromXContent(XContentParser parser) throws IOException {
    Builder builder = new Builder(parser.currentName());

    String currentFieldName = null;
    XContentParser.Token token = parser.nextToken();
    if (token == null) {
        // no data...
        return builder.build();
    }
    while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
        if (token == XContentParser.Token.FIELD_NAME) {
            currentFieldName = parser.currentName();
        } else if (token == XContentParser.Token.START_OBJECT) {
            if ("filter".equals(currentFieldName)) {
                Map<String, Object> filter = parser.mapOrdered();
                builder.filter(filter);
            }
        } else if (token == XContentParser.Token.VALUE_EMBEDDED_OBJECT) {
            if ("filter".equals(currentFieldName)) {
                builder.filter(new CompressedXContent(parser.binaryValue()));
            }
        } else if (token == XContentParser.Token.VALUE_STRING) {
            if ("routing".equals(currentFieldName)) {
                builder.routing(parser.text());
            } else if ("index_routing".equals(currentFieldName) || "indexRouting".equals(currentFieldName)) {
                builder.indexRouting(parser.text());
            } else if ("search_routing".equals(currentFieldName) || "searchRouting".equals(currentFieldName)) {
                builder.searchRouting(parser.text());
            }
        }
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:AliasMetaData.java

示例14: parse

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
@Override
public void parse(XContentParser parser, SQLXContentSourceContext context) throws Exception {
    XContentParser.Token token = parser.currentToken();

    if (token != XContentParser.Token.START_ARRAY) {
        throw new SQLParseSourceException(context, "Field [" + parser.currentName() + "] has an invalid value");
    }

    Object[] params = parseSubArray(context, parser);
    context.args(params);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:SQLArgsParseElement.java

示例15: innerParseCreateField

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
@Override
protected void innerParseCreateField(ParseContext context, List<Field> fields) throws IOException {
    byte value;
    float boost = fieldType().boost();
    if (context.externalValueSet()) {
        Object externalValue = context.externalValue();
        if (externalValue == null) {
            if (fieldType().nullValue() == null) {
                return;
            }
            value = fieldType().nullValue();
        } else if (externalValue instanceof String) {
            String sExternalValue = (String) externalValue;
            if (sExternalValue.length() == 0) {
                if (fieldType().nullValue() == null) {
                    return;
                }
                value = fieldType().nullValue();
            } else {
                value = Byte.parseByte(sExternalValue);
            }
        } else {
            value = ((Number) externalValue).byteValue();
        }
        if (context.includeInAll(includeInAll, this)) {
            context.allEntries().addText(fieldType().names().fullName(), Byte.toString(value), boost);
        }
    } else {
        XContentParser parser = context.parser();
        if (parser.currentToken() == XContentParser.Token.VALUE_NULL ||
                (parser.currentToken() == XContentParser.Token.VALUE_STRING && parser.textLength() == 0)) {
            if (fieldType().nullValue() == null) {
                return;
            }
            value = fieldType().nullValue();
            if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) {
                context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost);
            }
        } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
            XContentParser.Token token;
            String currentFieldName = null;
            Byte objValue = fieldType().nullValue();
            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                if (token == XContentParser.Token.FIELD_NAME) {
                    currentFieldName = parser.currentName();
                } else {
                    if ("value".equals(currentFieldName) || "_value".equals(currentFieldName)) {
                        if (parser.currentToken() != XContentParser.Token.VALUE_NULL) {
                            objValue = (byte) parser.shortValue(coerce.value());
                        }
                    } else if ("boost".equals(currentFieldName) || "_boost".equals(currentFieldName)) {
                        boost = parser.floatValue();
                    } else {
                        throw new IllegalArgumentException("unknown property [" + currentFieldName + "]");
                    }
                }
            }
            if (objValue == null) {
                // no value
                return;
            }
            value = objValue;
        } else {
            value = (byte) parser.shortValue(coerce.value());
            if (context.includeInAll(includeInAll, this)) {
                context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost);
            }
        }
    }
    if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
        CustomByteNumericField field = new CustomByteNumericField(value, fieldType());
        field.setBoost(boost);
        fields.add(field);
    }
    if (fieldType().hasDocValues()) {
        addDocValue(context, fields, value);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:79,代码来源:ByteFieldMapper.java


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