Search in sources :

Example 31 with ElasticsearchGenerationException

use of org.elasticsearch.ElasticsearchGenerationException in project crate by crate.

the class PutIndexTemplateRequest method aliases.

/**
 * Sets the aliases that will be associated with the index when it gets created
 */
@SuppressWarnings("unchecked")
public PutIndexTemplateRequest aliases(Map source) {
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.map(source);
        return aliases(BytesReference.bytes(builder));
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
    }
}
Also used : IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Example 32 with ElasticsearchGenerationException

use of org.elasticsearch.ElasticsearchGenerationException in project crate by crate.

the class PutMappingRequest method source.

/**
 * The mapping source definition.
 */
@SuppressWarnings("unchecked")
public PutMappingRequest source(Map mappingSource) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(mappingSource);
        return source(Strings.toString(builder), XContentType.JSON);
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to generate [" + mappingSource + "]", e);
    }
}
Also used : IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Example 33 with ElasticsearchGenerationException

use of org.elasticsearch.ElasticsearchGenerationException in project crate by crate.

the class UpdateSettingsRequest method settings.

/**
 * Sets the settings to be updated (either json or yaml format)
 */
@SuppressWarnings("unchecked")
public UpdateSettingsRequest settings(Map source) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(source);
        settings(Strings.toString(builder), builder.contentType());
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
    }
    return this;
}
Also used : IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Example 34 with ElasticsearchGenerationException

use of org.elasticsearch.ElasticsearchGenerationException in project crate by crate.

the class ClusterUpdateSettingsRequest method persistentSettings.

/**
 * Sets the persistent settings to be updated. They will get applied cross restarts
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public ClusterUpdateSettingsRequest persistentSettings(Map source) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(source);
        persistentSettings(Strings.toString(builder), builder.contentType());
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
    }
    return this;
}
Also used : IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Example 35 with ElasticsearchGenerationException

use of org.elasticsearch.ElasticsearchGenerationException in project crate by crate.

the class CreateSnapshotRequest method settings.

/**
 * Sets repository-specific snapshot settings.
 * <p>
 * See repository documentation for more information.
 *
 * @param source repository-specific snapshot settings
 * @return this request
 */
public CreateSnapshotRequest settings(Map<String, Object> source) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(source);
        settings(Strings.toString(builder), builder.contentType());
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
    }
    return this;
}
Also used : IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Aggregations

IOException (java.io.IOException)37 ElasticsearchGenerationException (org.elasticsearch.ElasticsearchGenerationException)37 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)35 UncheckedIOException (java.io.UncheckedIOException)15 BytesReference (org.elasticsearch.common.bytes.BytesReference)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 FileContext (org.apache.hadoop.fs.FileContext)1 CompressedXContent (org.elasticsearch.common.compress.CompressedXContent)1 XContentType (org.elasticsearch.common.xcontent.XContentType)1 GetResult (org.elasticsearch.index.get.GetResult)1 InvalidTypeNameException (org.elasticsearch.indices.InvalidTypeNameException)1 TypeMissingException (org.elasticsearch.indices.TypeMissingException)1