Package org.elasticsearch.common.xcontent

Examples of org.elasticsearch.common.xcontent.XContentBuilder.prettyPrint()


      // default to JSON
      contentType = XContentType.JSON;
    }
    XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput());
    if (request.paramAsBoolean("pretty", false)) {
      builder.prettyPrint().lfAtEnd();
    }
    String casing = request.param("case");
    if (casing != null && "camelCase".equals(casing)) {
      builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
    } else {
View Full Code Here


      // default to JSON
      contentType = XContentType.JSON;
    }
    XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput());
    if (request.paramAsBoolean("pretty", false)) {
      builder.prettyPrint().lfAtEnd();
    }
    String casing = request.param("case");
    if (casing != null && "camelCase".equals(casing)) {
      builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
    } else {
View Full Code Here

                    fos = new LZFOutputStream(fos);
                }
                LocalGatewayMetaState stateToWrite = builder.build();
                XContentBuilder xContentBuilder = XContentFactory.contentBuilder(XContentType.JSON, fos);
                if (prettyPrint) {
                    xContentBuilder.prettyPrint();
                }
                xContentBuilder.startObject();
                LocalGatewayMetaState.Builder.toXContent(stateToWrite, xContentBuilder, ToXContent.EMPTY_PARAMS);
                xContentBuilder.endObject();
                xContentBuilder.close();
View Full Code Here

                    fos = new LZFOutputStream(fos);
                }

                XContentBuilder xContentBuilder = XContentFactory.contentBuilder(XContentType.JSON, fos);
                if (prettyPrint) {
                    xContentBuilder.prettyPrint();
                }
                xContentBuilder.startObject();
                LocalGatewayStartedShards.Builder.toXContent(stateToWrite, xContentBuilder, ToXContent.EMPTY_PARAMS);
                xContentBuilder.endObject();
                xContentBuilder.close();
View Full Code Here

public abstract class BaseQueryBuilder implements QueryBuilder {

    @Override public String toString() {
        try {
            XContentBuilder builder = XContentFactory.safeJsonBuilder();
            builder.prettyPrint();
            toXContent(builder, EMPTY_PARAMS);
            return builder.string();
        } catch (Exception e) {
            throw new QueryBuilderException("Failed to build query", e);
        }
View Full Code Here

            contentType = XContentType.JSON;
        }
        CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry();
        XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), cachedEntry.cachedBytes(), cachedEntry);
        if (request.paramAsBoolean("pretty", false)) {
            builder.prettyPrint();
        }
        String casing = request.param("case");
        if (casing != null && "camelCase".equals(casing)) {
            builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
        } else {
View Full Code Here

      // default to JSON
      contentType = XContentType.JSON;
    }
    XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput());
    if (request.paramAsBoolean("pretty", false)) {
      builder.prettyPrint().lfAtEnd();
    }
    String casing = request.param("case");
    if (casing != null && "camelCase".equals(casing)) {
      builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
    } else {
View Full Code Here

            contentType = XContentType.JSON;
        }
        XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType),
                new BytesStreamOutput());
        if (request.paramAsBoolean("pretty", false)) {
            builder.prettyPrint().lfAtEnd();
        }
        String casing = request.param("case");
        if (casing != null && "camelCase".equals(casing)) {
            builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
        } else {
View Full Code Here

    public static String toString(ToXContent tmp) {
        try {
            XContentBuilder builder = JsonXContent.unCachedContentBuilder();
            tmp.toXContent(builder, ToXContent.EMPTY_PARAMS);
            return builder.prettyPrint().string();
        } catch (Exception ex) {
            return "<ERROR:" + ex.getMessage() + ">";
        }
    }
View Full Code Here

        entries.add(urlEntry);

        tw.setUrlEntries(entries);

        XContentBuilder iDoc = twSearch.createDoc(tw);
        String str = iDoc.prettyPrint().string();
        assertTrue(str.contains("\"url_pos_1_s\":\"2,18\""));
        assertTrue(str.contains("\"dest_url_1_s\":\"http://fulltest.de/bla\""));
        assertTrue(str.contains("\"dest_domain_1_s\":\"resolved-domain.de\""));
        assertTrue(str.contains("\"dest_title_1_s\":\"ResolvedTitel\""));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.