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


Java XContentParser.mapOrdered方法代码示例

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


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

示例1: 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

示例2: fromXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
/**
 * Parses an alias and returns its parsed representation
 */
public static Alias fromXContent(XContentParser parser) throws IOException {
    Alias alias = new Alias(parser.currentName());

    String currentFieldName = null;
    XContentParser.Token token = parser.nextToken();
    if (token == null) {
        throw new IllegalArgumentException("No alias is specified");
    }
    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();
                alias.filter(filter);
            }
        } else if (token == XContentParser.Token.VALUE_STRING) {
            if ("routing".equals(currentFieldName)) {
                alias.routing(parser.text());
            } else if ("index_routing".equals(currentFieldName) || "indexRouting".equals(currentFieldName) || "index-routing".equals(currentFieldName)) {
                alias.indexRouting(parser.text());
            } else if ("search_routing".equals(currentFieldName) || "searchRouting".equals(currentFieldName) || "search-routing".equals(currentFieldName)) {
                alias.searchRouting(parser.text());
            }
        }
    }
    return alias;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:Alias.java

示例3: toXContent

import org.elasticsearch.common.xcontent.XContentParser; //导入方法依赖的package包/类
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
    /**
     * array mapping should look like:
     *
     * "fieldName": {
     *      "type": "array":
     *      "inner": {
     *          "type": "string"
     *          ...
     *      }
     * }
     *
     *
     * Use the innerMapper to generate the mapping for the inner type which will look like:
     *
     * "fieldName": {
     *      "type": "string",
     *      ...
     * }
     *
     * and then parse the contents of the object to set it into the "inner" field of the outer array type.
     */
    XContentBuilder innerBuilder = new XContentBuilder(builder.contentType().xContent(), new BytesStreamOutput(0));
    innerBuilder = innerMapper.toXContent(innerBuilder, params);
    innerBuilder.close();
    XContentParser parser = builder.contentType().xContent().createParser(innerBuilder.bytes());

    //noinspection StatementWithEmptyBody
    while ((parser.nextToken() != XContentParser.Token.START_OBJECT)) {
        // consume tokens until start of object
    }
    Map<String, Object> innerMap = parser.mapOrdered();

    builder.startObject(simpleName());
    builder.field("type", contentType());
    builder.field(INNER, innerMap);
    return builder.endObject();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:40,代码来源:ArrayMapper.java


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