Package org.elasticsearch.search.builder

Examples of org.elasticsearch.search.builder.SearchSourceBuilderException


        return this;
    }

    @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
        if (script == null) {
            throw new SearchSourceBuilderException("script must be set on statistical script facet [" + name + "]");
        }
        builder.startObject(name);

        builder.startObject(StatisticalFacet.TYPE);
        builder.field("script", script);
View Full Code Here


    }


    @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
        if (keyFieldName == null) {
            throw new SearchSourceBuilderException("field must be set on date histogram facet for facet [" + name + "]");
        }
        if (interval == null) {
            throw new SearchSourceBuilderException("interval must be set on date histogram facet for facet [" + name + "]");
        }
        builder.startObject(name);

        builder.startObject(DateHistogramFacet.TYPE);
        if (valueFieldName != null) {
View Full Code Here

    }

    @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 + "]");
        }
        if(interval == null) {
            throw new SearchSourceBuilderException("interval must be set on date histogram facet for facet [" + name + "]");
        }
        builder.startObject(name);

        builder.startObject("date_facet");
View Full Code Here

     * 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;
    }
View Full Code Here

    @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);
        }
View Full Code Here

    @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();
    }
View Full Code Here

    }

    @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");
View Full Code Here

    }

    @Override
    protected XContentBuilder doInternalXContent(XContentBuilder builder, Params params) throws IOException {
        if (interval == null) {
            throw new SearchSourceBuilderException("[interval] must be defined for histogram aggregation [" + getName() + "]");
        }
        if (interval instanceof Number) {
            interval = TimeValue.timeValueMillis(((Number) interval).longValue()).toString();
        }
        builder.field("interval", interval);
View Full Code Here

    @Override
    protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException {
        builder.startObject();
        if (keyedFilters == null && nonKeyedFilters == null) {
            throw new SearchSourceBuilderException("At least one filter must be set on filter aggregation [" + getName() + "]");
        }
        if (keyedFilters != null && nonKeyedFilters != null) {
            throw new SearchSourceBuilderException("Cannot add both keyed and non-keyed filters to filters aggregation");
        }
       
        if (keyedFilters != null) {
            builder.startObject("filters");
            for (Map.Entry<String, FilterBuilder> entry : keyedFilters.entrySet()) {
View Full Code Here

    }

    @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);
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.search.builder.SearchSourceBuilderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.