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;
}
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));
}
use of org.opensearch.common.ParseField in project OpenSearch by opensearch-project.
the class SearchHit method declareInnerHitsParseFields.
public static void declareInnerHitsParseFields(ObjectParser<Map<String, Object>, Void> parser) {
parser.declareString((map, value) -> map.put(Fields._INDEX, value), new ParseField(Fields._INDEX));
parser.declareString((map, value) -> map.put(Fields._ID, value), new ParseField(Fields._ID));
parser.declareString((map, value) -> map.put(Fields._NODE, value), new ParseField(Fields._NODE));
parser.declareField((map, value) -> map.put(Fields._SCORE, value), SearchHit::parseScore, new ParseField(Fields._SCORE), ValueType.FLOAT_OR_NULL);
parser.declareLong((map, value) -> map.put(Fields._VERSION, value), new ParseField(Fields._VERSION));
parser.declareLong((map, value) -> map.put(Fields._SEQ_NO, value), new ParseField(Fields._SEQ_NO));
parser.declareLong((map, value) -> map.put(Fields._PRIMARY_TERM, value), new ParseField(Fields._PRIMARY_TERM));
parser.declareField((map, value) -> map.put(Fields._SHARD, value), (p, c) -> ShardId.fromString(p.text()), new ParseField(Fields._SHARD), ValueType.STRING);
parser.declareObject((map, value) -> map.put(SourceFieldMapper.NAME, value), (p, c) -> parseSourceBytes(p), new ParseField(SourceFieldMapper.NAME));
parser.declareObject((map, value) -> map.put(Fields.HIGHLIGHT, value), (p, c) -> parseHighlightFields(p), new ParseField(Fields.HIGHLIGHT));
parser.declareObject((map, value) -> {
Map<String, DocumentField> fieldMap = get(Fields.FIELDS, map, new HashMap<String, DocumentField>());
fieldMap.putAll(value);
map.put(DOCUMENT_FIELDS, fieldMap);
}, (p, c) -> parseFields(p), new ParseField(Fields.FIELDS));
parser.declareObject((map, value) -> map.put(Fields._EXPLANATION, value), (p, c) -> parseExplanation(p), new ParseField(Fields._EXPLANATION));
parser.declareObject((map, value) -> map.put(NestedIdentity._NESTED, value), NestedIdentity::fromXContent, new ParseField(NestedIdentity._NESTED));
parser.declareObject((map, value) -> map.put(Fields.INNER_HITS, value), (p, c) -> parseInnerHits(p), new ParseField(Fields.INNER_HITS));
parser.declareStringArray((map, list) -> map.put(Fields.MATCHED_QUERIES, list), new ParseField(Fields.MATCHED_QUERIES));
parser.declareField((map, list) -> map.put(Fields.SORT, list), SearchSortValues::fromXContent, new ParseField(Fields.SORT), ValueType.OBJECT_ARRAY);
}
use of org.opensearch.common.ParseField in project OpenSearch by opensearch-project.
the class ParsedStats method declareStatsFields.
protected static void declareStatsFields(ObjectParser<? extends ParsedStats, Void> objectParser) {
declareAggregationFields(objectParser);
objectParser.declareLong((agg, value) -> agg.count = value, new ParseField(Fields.COUNT));
objectParser.declareField((agg, value) -> agg.min = value, (parser, context) -> parseDouble(parser, Double.POSITIVE_INFINITY), new ParseField(Fields.MIN), ValueType.DOUBLE_OR_NULL);
objectParser.declareField((agg, value) -> agg.max = value, (parser, context) -> parseDouble(parser, Double.NEGATIVE_INFINITY), new ParseField(Fields.MAX), ValueType.DOUBLE_OR_NULL);
objectParser.declareField((agg, value) -> agg.avg = value, (parser, context) -> parseDouble(parser, 0), new ParseField(Fields.AVG), ValueType.DOUBLE_OR_NULL);
objectParser.declareField((agg, value) -> agg.sum = value, (parser, context) -> parseDouble(parser, 0), new ParseField(Fields.SUM), ValueType.DOUBLE_OR_NULL);
objectParser.declareString((agg, value) -> agg.valueAsString.put(Fields.MIN_AS_STRING, value), new ParseField(Fields.MIN_AS_STRING));
objectParser.declareString((agg, value) -> agg.valueAsString.put(Fields.MAX_AS_STRING, value), new ParseField(Fields.MAX_AS_STRING));
objectParser.declareString((agg, value) -> agg.valueAsString.put(Fields.AVG_AS_STRING, value), new ParseField(Fields.AVG_AS_STRING));
objectParser.declareString((agg, value) -> agg.valueAsString.put(Fields.SUM_AS_STRING, value), new ParseField(Fields.SUM_AS_STRING));
}
use of org.opensearch.common.ParseField in project job-scheduler by opensearch-project.
the class JobSchedulerPlugin method getNamedXContent.
public List<NamedXContentRegistry.Entry> getNamedXContent() {
List<NamedXContentRegistry.Entry> registryEntries = new ArrayList<>();
// register schedule
NamedXContentRegistry.Entry scheduleEntry = new NamedXContentRegistry.Entry(Schedule.class, new ParseField("schedule"), ScheduleParser::parse);
registryEntries.add(scheduleEntry);
return registryEntries;
}
Aggregations