/*
 * Licensed to ElasticSearch and Shay Banon under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. ElasticSearch licenses this
 * file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.elasticsearch.index.query;

import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;

/**
 *
 */
public abstract class BaseFilterBuilder implements FilterBuilder {

    @Override
    public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
        builder.startObject();
        doXContent(builder, params);
        builder.endObject();
        return builder;
    }

    protected abstract void doXContent(XContentBuilder builder, Params params) throws IOException;
}
@@ -897,16 +897,74 @@
 Builder;
+%0Aimport org.elasticsearch.common.xcontent.XContentFactory;
 %0A%0Aimport
@@ -1065,16 +1065,386 @@
 lder %7B%0A%0A
+    @Override%0A    public String toString() %7B%0A        try %7B%0A            XContentBuilder builder = XContentFactory.jsonBuilder();%0A            builder.prettyPrint();%0A            toXContent(builder, EMPTY_PARAMS);%0A            return builder.string();%0A        %7D catch (Exception e) %7B%0A            throw new QueryBuilderException(%22Failed to build filter%22, e);%0A        %7D%0A    %7D%0A%0A
     @Ove
@@ -1775,9 +1775,10 @@
 eption;%0A
-
 %7D
+%0A

Add toString() for FilterBuilders Closes #2887.