@Override public Long parse(XContentParser parser, boolean coerce) throws IOException { return parser.longValue(coerce); }
static ParsedBucket fromXContent(XContentParser parser, boolean keyed) throws IOException { return parseXContent(parser, keyed, ParsedBucket::new, (p, bucket) -> bucket.key = p.longValue()); } }
static ParsedBucket fromXContent(XContentParser parser, boolean keyed) throws IOException { return parseXContent(parser, keyed, ParsedBucket::new, (p, bucket) -> bucket.key = p.longValue()); } }
static ParsedBucket fromXContent(XContentParser parser) throws IOException { return parseTermsBucketXContent(parser, ParsedBucket::new, (p, bucket) -> bucket.key = p.longValue()); } }
static ParsedBucket fromXContent(XContentParser parser) throws IOException { return parseSignificantTermsBucketXContent(parser, new ParsedBucket(), (p, bucket) -> bucket.key = p.longValue()); } }
public static MaxDocsCondition fromXContent(XContentParser parser) throws IOException { if (parser.nextToken() == XContentParser.Token.VALUE_NUMBER) { return new MaxDocsCondition(parser.longValue()); } else { throw new IllegalArgumentException("invalid token: " + parser.currentToken()); } } }
static <B extends ParsedBucket> B parseTermsBucketXContent(final XContentParser parser, final Supplier<B> bucketSupplier, final CheckedBiConsumer<XContentParser, B, IOException> keyConsumer) throws IOException { final B bucket = bucketSupplier.get(); final List<Aggregation> aggregations = new ArrayList<>(); XContentParser.Token token; String currentFieldName = parser.currentName(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { if (CommonFields.KEY_AS_STRING.getPreferredName().equals(currentFieldName)) { bucket.setKeyAsString(parser.text()); } else if (CommonFields.KEY.getPreferredName().equals(currentFieldName)) { keyConsumer.accept(parser, bucket); } else if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { bucket.setDocCount(parser.longValue()); } else if (DOC_COUNT_ERROR_UPPER_BOUND_FIELD_NAME.getPreferredName().equals(currentFieldName)) { bucket.docCountError = parser.longValue(); bucket.showDocCountError = true; } } else if (token == XContentParser.Token.START_OBJECT) { XContentParserUtils.parseTypedKeysObject(parser, Aggregation.TYPED_KEYS_DELIMITER, Aggregation.class, aggregations::add); } } bucket.setAggregations(new Aggregations(aggregations)); return bucket; } }
keyConsumer.accept(parser, bucket); } else if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { long value = parser.longValue(); bucket.subsetDf = value; bucket.setDocCount(value); bucket.score = parser.doubleValue(); } else if (InternalSignificantTerms.BG_COUNT.equals(currentFieldName)) { bucket.supersetDf = parser.longValue();
} else if (token.isValue()) { if (Fields.TOTAL.equals(currentFieldName)) { totalHits = parser.longValue(); } else if (Fields.MAX_SCORE.equals(currentFieldName)) { maxScore = parser.floatValue();
values.add(parser.longValue()); break;
} else if (token.isValue()) { if (REWRITE_TIME.equals(currentFieldName)) { rewriteTime = parser.longValue(); } else { parser.skipChildren();
context.setId(parser.text()); } else if (_VERSION.equals(currentFieldName)) { context.setVersion(parser.longValue()); } else if (RESULT.equals(currentFieldName)) { String result = parser.text(); context.setForcedRefresh(parser.booleanValue()); } else if (_SEQ_NO.equals(currentFieldName)) { context.setSeqNo(parser.longValue()); } else if (_PRIMARY_TERM.equals(currentFieldName)) { context.setPrimaryTerm(parser.longValue());
bucket.key = parser.text(); } else if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { bucket.setDocCount(parser.longValue()); } else if (CommonFields.FROM.getPreferredName().equals(currentFieldName)) { bucket.from = parser.doubleValue();
} else if (token.isValue()) { if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { aggregation.setDocCount(parser.longValue());
keyConsumer.accept(parser, bucket); } else if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { bucket.setDocCount(parser.longValue());
bucket.key = parser.text(); } else if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { bucket.setDocCount(parser.longValue()); } else if (CommonFields.FROM.getPreferredName().equals(currentFieldName)) { bucket.from = parser.text();
static ParsedBucket fromXContent(XContentParser parser, boolean keyed) throws IOException { final ParsedBucket bucket = new ParsedBucket(); bucket.setKeyed(keyed); XContentParser.Token token = parser.currentToken(); String currentFieldName = parser.currentName(); if (keyed) { ensureExpectedToken(XContentParser.Token.FIELD_NAME, token, parser::getTokenLocation); bucket.key = currentFieldName; ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser::getTokenLocation); } List<Aggregation> aggregations = new ArrayList<>(); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token.isValue()) { if (CommonFields.DOC_COUNT.getPreferredName().equals(currentFieldName)) { bucket.setDocCount(parser.longValue()); } } else if (token == XContentParser.Token.START_OBJECT) { XContentParserUtils.parseTypedKeysObject(parser, Aggregation.TYPED_KEYS_DELIMITER, Aggregation.class, aggregations::add); } } bucket.setAggregations(new Aggregations(aggregations)); return bucket; } }
randomScoreFunctionBuilder.seed(parser.intValue()); } else if (parser.numberType() == XContentParser.NumberType.LONG) { randomScoreFunctionBuilder.seed(parser.longValue()); } else { throw new ParsingException(parser.getTokenLocation(), "random_score seed must be an int, long or string, not '"
time = parser.longValue(); } else { parser.skipChildren();