Search in sources :

Example 31 with ParseField

use of org.opensearch.common.ParseField in project OpenSearch by opensearch-project.

the class ParsedSignificantTerms method declareParsedSignificantTermsFields.

static void declareParsedSignificantTermsFields(final ObjectParser<? extends ParsedSignificantTerms, Void> objectParser, final CheckedFunction<XContentParser, ParsedSignificantTerms.ParsedBucket, IOException> bucketParser) {
    declareMultiBucketAggregationFields(objectParser, bucketParser::apply, bucketParser::apply);
    objectParser.declareLong((parsedTerms, value) -> parsedTerms.subsetSize = value, CommonFields.DOC_COUNT);
    objectParser.declareLong((parsedTerms, value) -> parsedTerms.supersetSize = value, new ParseField(InternalMappedSignificantTerms.BG_COUNT));
}
Also used : ParseField(org.opensearch.common.ParseField)

Example 32 with ParseField

use of org.opensearch.common.ParseField in project OpenSearch by opensearch-project.

the class NodesResponse method declareCommonNodesResponseParsing.

public static <T extends NodesResponse> void declareCommonNodesResponseParsing(ConstructingObjectParser<T, Void> parser) {
    parser.declareObject(ConstructingObjectParser.constructorArg(), NodesResponseHeader::fromXContent, new ParseField("_nodes"));
    parser.declareString(ConstructingObjectParser.constructorArg(), new ParseField("cluster_name"));
}
Also used : ParseField(org.opensearch.common.ParseField)

Example 33 with ParseField

use of org.opensearch.common.ParseField in project OpenSearch by opensearch-project.

the class InternalParentTests method getNamedXContents.

@Override
protected List<Entry> getNamedXContents() {
    List<Entry> extendedNamedXContents = new ArrayList<>(super.getNamedXContents());
    extendedNamedXContents.add(new Entry(Aggregation.class, new ParseField(ParentAggregationBuilder.NAME), (p, c) -> ParsedParent.fromXContent(p, (String) c)));
    return extendedNamedXContents;
}
Also used : Aggregation(org.opensearch.search.aggregations.Aggregation) ParsedSingleBucketAggregation(org.opensearch.search.aggregations.bucket.ParsedSingleBucketAggregation) InternalSingleBucketAggregationTestCase(org.opensearch.search.aggregations.InternalSingleBucketAggregationTestCase) List(java.util.List) Aggregation(org.opensearch.search.aggregations.Aggregation) ParsedSingleBucketAggregation(org.opensearch.search.aggregations.bucket.ParsedSingleBucketAggregation) Entry(org.opensearch.common.xcontent.NamedXContentRegistry.Entry) ParentJoinPlugin(org.opensearch.join.ParentJoinPlugin) InternalAggregations(org.opensearch.search.aggregations.InternalAggregations) Map(java.util.Map) SearchPlugin(org.opensearch.plugins.SearchPlugin) ParseField(org.opensearch.common.ParseField) ArrayList(java.util.ArrayList) Entry(org.opensearch.common.xcontent.NamedXContentRegistry.Entry) ArrayList(java.util.ArrayList) ParseField(org.opensearch.common.ParseField)

Example 34 with ParseField

use of org.opensearch.common.ParseField in project OpenSearch by opensearch-project.

the class ParentJoinNamedXContentProvider method getNamedXContentParsers.

@Override
public List<NamedXContentRegistry.Entry> getNamedXContentParsers() {
    ParseField parseFieldChildren = new ParseField(ChildrenAggregationBuilder.NAME);
    ParseField parseFieldParent = new ParseField(ParentAggregationBuilder.NAME);
    ContextParser<Object, Aggregation> contextParserChildren = (p, name) -> ParsedChildren.fromXContent(p, (String) name);
    ContextParser<Object, Aggregation> contextParserParent = (p, name) -> ParsedParent.fromXContent(p, (String) name);
    return Arrays.asList(new NamedXContentRegistry.Entry(Aggregation.class, parseFieldChildren, contextParserChildren), new NamedXContentRegistry.Entry(Aggregation.class, parseFieldParent, contextParserParent));
}
Also used : Aggregation(org.opensearch.search.aggregations.Aggregation) Arrays(java.util.Arrays) List(java.util.List) ParentAggregationBuilder(org.opensearch.join.aggregations.ParentAggregationBuilder) ParsedParent(org.opensearch.join.aggregations.ParsedParent) Aggregation(org.opensearch.search.aggregations.Aggregation) NamedXContentProvider(org.opensearch.plugins.spi.NamedXContentProvider) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ContextParser(org.opensearch.common.xcontent.ContextParser) ChildrenAggregationBuilder(org.opensearch.join.aggregations.ChildrenAggregationBuilder) ParsedChildren(org.opensearch.join.aggregations.ParsedChildren) ParseField(org.opensearch.common.ParseField) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ParseField(org.opensearch.common.ParseField)

Example 35 with ParseField

use of org.opensearch.common.ParseField 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)66 NamedObjectParser (org.opensearch.common.xcontent.ObjectParser.NamedObjectParser)26 Matchers.containsString (org.hamcrest.Matchers.containsString)15 List (java.util.List)14 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)9 Map (java.util.Map)7 NamedXContentRegistry (org.opensearch.common.xcontent.NamedXContentRegistry)6 Aggregation (org.opensearch.search.aggregations.Aggregation)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 UncheckedIOException (java.io.UncheckedIOException)5 HashMap (java.util.HashMap)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 JsonXContent (org.opensearch.common.xcontent.json.JsonXContent)4 Collections (java.util.Collections)3 OpenSearchException (org.opensearch.OpenSearchException)3 ExplainResponse (org.opensearch.action.explain.ExplainResponse)3 NamedObject (org.opensearch.common.xcontent.ObjectParserTests.NamedObject)3 XContentParser (org.opensearch.common.xcontent.XContentParser)3 URI (java.net.URI)2