Examples of XContentType


Examples of org.elasticsearch.common.xcontent.XContentType

  private ContentBuilderUtil() {
  }

  public static void appendField(XContentBuilder builder, String field,
      byte[] data) throws IOException {
    XContentType contentType = XContentFactory.xContentType(data);
    if (contentType == null) {
      addSimpleField(builder, field, data);
    } else {
      addComplexField(builder, field, contentType, data);
    }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestXContentBuilder {

  public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
    XContentType contentType = XContentType
        .fromRestContentType(request.param("format", request.header("Content-Type")));
    if (contentType == null) {
      // default to JSON
      contentType = XContentType.JSON;
    }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestXContentBuilder {

  public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
    XContentType contentType = XContentType
        .fromRestContentType(request.param("format", request.header("Content-Type")));
    if (contentType == null) {
      // default to JSON
      contentType = XContentType.JSON;
    }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

    @SuppressWarnings({"unchecked"})
    @Override public void handleRequest(final RestRequest request, final RestChannel channel) {
        CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index"));
        if (request.hasContent()) {
            XContentType xContentType = XContentFactory.xContentType(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength());
            if (xContentType != null) {
                try {
                    Map<String, Object> source = XContentFactory.xContent(xContentType)
                            .createParser(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength()).mapAndClose();
                    boolean found = false;
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

        XContentParser parser = null;
        try {
            if (LZF.isCompressed(bytes, offset, length)) {
                BytesStreamInput siBytes = new BytesStreamInput(bytes, offset, length);
                LZFStreamInput siLzf = CachedStreamInput.cachedLzf(siBytes);
                XContentType contentType = XContentFactory.xContentType(siLzf);
                siLzf.resetToBufferStart();
                parser = XContentFactory.xContent(contentType).createParser(siLzf);
                return parser.map();
            } else {
                parser = XContentFactory.xContent(bytes, offset, length).createParser(bytes, offset, length);
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

        try {
            if (parser == null) {
                if (LZF.isCompressed(source.source())) {
                    BytesStreamInput siBytes = new BytesStreamInput(source.source());
                    LZFStreamInput siLzf = CachedStreamInput.cachedLzf(siBytes);
                    XContentType contentType = XContentFactory.xContentType(siLzf);
                    siLzf.resetToBufferStart();
                    parser = XContentFactory.xContent(contentType).createParser(siLzf);
                } else {
                    parser = XContentFactory.xContent(source.source()).createParser(source.source());
                }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

* @author kimchy (shay.banon)
*/
public class RestXContentBuilder {

    public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
        XContentType contentType = XContentType.fromRestContentType(request.header("Content-Type"));
        if (contentType == null) {
            // try and guess it from the body, if exists
            if (request.hasContent()) {
                contentType = XContentFactory.xContentType(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength());
            }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

    public static void restDocumentSource(byte[] source, int offset, int length, XContentBuilder builder, ToXContent.Params params) throws IOException {
        if (LZF.isCompressed(source, offset, length)) {
            BytesStreamInput siBytes = new BytesStreamInput(source, offset, length);
            LZFStreamInput siLzf = CachedStreamInput.cachedLzf(siBytes);
            XContentType contentType = XContentFactory.xContentType(siLzf);
            siLzf.resetToBufferStart();
            if (contentType == builder.contentType()) {
                builder.rawField("_source", siLzf);
            } else {
                XContentParser parser = XContentFactory.xContent(contentType).createParser(siLzf);
                try {
                    parser.nextToken();
                    builder.field("_source");
                    builder.copyCurrentStructure(parser);
                } finally {
                    parser.close();
                }
            }
        } else {
            XContentType contentType = XContentFactory.xContentType(source, offset, length);
            if (contentType == builder.contentType()) {
                builder.rawField("_source", source, offset, length);
            } else {
                XContentParser parser = XContentFactory.xContent(contentType).createParser(source);
                try {
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

  private ContentBuilderUtil() {
  }

  public static void appendField(XContentBuilder builder, String field,
      byte[] data) throws IOException {
    XContentType contentType = XContentFactory.xContentType(data);
    if (contentType == null) {
      addSimpleField(builder, field, data);
    } else {
      addComplexField(builder, field, contentType, data);
    }
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentType

* @author Vlastimil Elias (velias at redhat dot com)
*/
public class RestXContentBuilder {

  public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
    XContentType contentType = XContentType
        .fromRestContentType(request.param("format", request.header("Content-Type")));
    if (contentType == null) {
      // default to JSON
      contentType = XContentType.JSON;
    }
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.