Java Code Examples for org.elasticsearch.common.text.Text#hasString()

The following examples show how to use org.elasticsearch.common.text.Text#hasString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XContentBuilder.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public XContentBuilder field(String name, Text value) throws IOException {
    field(name);
    if (value.hasBytes() && value.bytes().hasArray()) {
        generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
        return this;
    }
    if (value.hasString()) {
        generator.writeString(value.string());
        return this;
    }
    // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?
    BytesArray bytesArray = value.bytes().toBytesArray();
    generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
    return this;
}
 
Example 2
Source File: XContentBuilder.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public XContentBuilder field(XContentBuilderString name, Text value) throws IOException {
    field(name);
    if (value.hasBytes() && value.bytes().hasArray()) {
        generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
        return this;
    }
    if (value.hasString()) {
        generator.writeString(value.string());
        return this;
    }
    // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?
    BytesArray bytesArray = value.bytes().toBytesArray();
    generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
    return this;
}
 
Example 3
Source File: XmlXContentBuilder.java    From elasticsearch-xml with Apache License 2.0 5 votes vote down vote up
public XmlXContentBuilder field(String name, Text value) throws IOException {
    field(name);
    if (value.hasBytes() && value.bytes().hasArray()) {
        generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
        return this;
    }
    if (value.hasString()) {
        generator.writeString(value.string());
        return this;
    }
    // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?
    BytesArray bytesArray = value.bytes().toBytesArray();
    generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
    return this;
}
 
Example 4
Source File: XmlXContentBuilder.java    From elasticsearch-xml with Apache License 2.0 5 votes vote down vote up
public XmlXContentBuilder field(XContentBuilderString name, Text value) throws IOException {
    field(name);
    if (value.hasBytes() && value.bytes().hasArray()) {
        generator.writeUTF8String(value.bytes().array(), value.bytes().arrayOffset(), value.bytes().length());
        return this;
    }
    if (value.hasString()) {
        generator.writeString(value.string());
        return this;
    }
    // TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a request to jackson to support InputStream as well?
    BytesArray bytesArray = value.bytes().toBytesArray();
    generator.writeUTF8String(bytesArray.array(), bytesArray.arrayOffset(), bytesArray.length());
    return this;
}