@Override protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (path == null) { throw new SearchSourceBuilderException("nested path must be set on nested aggregation [" + getName() + "]"); } builder.field("path", path); return builder.endObject(); } }
@Override protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (childType == null) { throw new SearchSourceBuilderException("child_type must be set on children aggregation [" + getName() + "]"); } builder.field("type", childType); return builder.endObject(); } }
@Override protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { if (filter == null) { throw new SearchSourceBuilderException("filter must be set on filter aggregation [" + getName() + "]"); } filter.toXContent(builder, params); return builder; } }
/** * Add a range based on a CIDR mask. */ public IPv4RangeBuilder addMaskRange(String key, String mask) { long[] fromTo = cidrMaskToMinMax(mask); if (fromTo == null) { throw new SearchSourceBuilderException("invalid CIDR mask [" + mask + "] in ip_range aggregation [" + getName() + "]"); } ranges.add(new Range(key, fromTo[0] < 0 ? null : fromTo[0], fromTo[1] < 0 ? null : fromTo[1])); return this; }
public BytesReference buildAsBytes(XContentType contentType) throws SearchSourceBuilderException { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); toXContent(builder, ToXContent.EMPTY_PARAMS); return builder.bytes(); } catch (Exception e) { throw new SearchSourceBuilderException("Failed to build search source", e); } }
public BytesReference buildAsBytes(XContentType contentType) throws SearchSourceBuilderException { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); toXContent(builder, ToXContent.EMPTY_PARAMS); return builder.bytes(); } catch (Exception e) { throw new SearchSourceBuilderException("Failed to build search source", e); } } }
@Override protected XContentBuilder doInternalXContent(XContentBuilder builder, Params params) throws IOException { if (ranges.isEmpty()) { throw new SearchSourceBuilderException("at least one range must be defined for range aggregation [" + getName() + "]"); } builder.startArray("ranges"); for (Range range : ranges) { range.toXContent(builder, params); } return builder.endArray(); } }
throw new SearchSourceBuilderException("field name must be set for term list facet [" + name + "]");
builder.startObject(); if (keyedFilters == null && nonKeyedFilters == null) { throw new SearchSourceBuilderException("At least one filter must be set on filter aggregation [" + getName() + "]"); throw new SearchSourceBuilderException("Cannot add both keyed and non-keyed filters to filters aggregation");
@Override protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (ranges.isEmpty()) { throw new SearchSourceBuilderException("at least one range must be defined for geo_distance aggregation [" + getName() + "]"); } if (point == null) { throw new SearchSourceBuilderException("center point must be defined for geo_distance aggregation [" + getName() + "]"); } if (field != null) { builder.field("field", field); } if (unit != null) { builder.field("unit", unit); } if (distanceType != null) { builder.field("distance_type", distanceType.name().toLowerCase(Locale.ROOT)); } builder.startObject("center") .field("lat", point.lat()) .field("lon", point.lon()) .endObject(); builder.startArray("ranges"); for (Range range : ranges) { range.toXContent(builder, params); } builder.endArray(); return builder.endObject(); }
@Override protected XContentBuilder doInternalXContent(XContentBuilder builder, Params params) throws IOException { if (interval == null) { throw new SearchSourceBuilderException("[interval] must be defined for histogram aggregation [" + getName() + "]"); } builder.field("interval", interval); if (order != null) { builder.field("order"); order.toXContent(builder, params); } if (offset != null) { builder.field("offset", offset); } if (minDocCount != null) { builder.field("min_doc_count", minDocCount); } if (extendedBoundsMin != null || extendedBoundsMax != null) { builder.startObject(HistogramParser.EXTENDED_BOUNDS.getPreferredName()); if (extendedBoundsMin != null) { builder.field("min", extendedBoundsMin); } if (extendedBoundsMax != null) { builder.field("max", extendedBoundsMax); } builder.endObject(); } return builder; }
@Override public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException { if(keyFieldName == null) { throw new SearchSourceBuilderException("field must be set on date histogram facet for facet [" + name + "]"); throw new SearchSourceBuilderException("interval must be set on date histogram facet for facet [" + name + "]");
@Override protected XContentBuilder doInternalXContent(XContentBuilder builder, Params params) throws IOException { if (interval == null) { throw new SearchSourceBuilderException("[interval] must be defined for histogram aggregation [" + getName() + "]");