Search in sources :

Example 1 with ObjectParser

use of org.opensearch.common.xcontent.ObjectParser in project OpenSearch by opensearch-project.

the class AbstractAllocateAllocationCommand method createAllocateParser.

protected static <T extends Builder<?>> ObjectParser<T, Void> createAllocateParser(String command) {
    ObjectParser<T, Void> parser = new ObjectParser<>(command);
    parser.declareString(Builder::setIndex, new ParseField(INDEX_FIELD));
    parser.declareInt(Builder::setShard, new ParseField(SHARD_FIELD));
    parser.declareString(Builder::setNode, new ParseField(NODE_FIELD));
    return parser;
}
Also used : ObjectParser(org.opensearch.common.xcontent.ObjectParser) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) ParseField(org.opensearch.common.ParseField)

Example 2 with ObjectParser

use of org.opensearch.common.xcontent.ObjectParser in project OpenSearch by opensearch-project.

the class JsonLogLine method createParser.

private static ObjectParser<JsonLogLine, Void> createParser(boolean ignoreUnknownFields) {
    ObjectParser<JsonLogLine, Void> parser = new ObjectParser<>("search_template", ignoreUnknownFields, JsonLogLine::new);
    parser.declareString(JsonLogLine::setType, new ParseField("type"));
    parser.declareString(JsonLogLine::setTimestamp, new ParseField("timestamp"));
    parser.declareString(JsonLogLine::setLevel, new ParseField("level"));
    parser.declareString(JsonLogLine::setComponent, new ParseField("component"));
    parser.declareString(JsonLogLine::setClusterName, new ParseField("cluster.name"));
    parser.declareString(JsonLogLine::setNodeName, new ParseField("node.name"));
    parser.declareString(JsonLogLine::setClusterUuid, new ParseField("cluster.uuid"));
    parser.declareString(JsonLogLine::setNodeId, new ParseField("node.id"));
    parser.declareString(JsonLogLine::setMessage, new ParseField("message"));
    parser.declareStringArray(JsonLogLine::setStacktrace, new ParseField("stacktrace"));
    return parser;
}
Also used : ObjectParser(org.opensearch.common.xcontent.ObjectParser) ParseField(org.opensearch.common.ParseField)

Aggregations

ParseField (org.opensearch.common.ParseField)2 ObjectParser (org.opensearch.common.xcontent.ObjectParser)2 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)1