Search in sources :

Example 16 with ElasticsearchGenerationException

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

the class Alias method filter.

/**
     * Associates a filter to the alias
     */
public Alias filter(QueryBuilder filterBuilder) {
    if (filterBuilder == null) {
        this.filter = null;
        return this;
    }
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        filterBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS);
        builder.close();
        this.filter = builder.string();
        return this;
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to build json for alias request", e);
    }
}
Also used : IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Example 17 with ElasticsearchGenerationException

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

the class ClusterUpdateSettingsRequest method transientSettings.

/**
     * Sets the transient settings to be updated. They will not survive a full cluster restart
     */
@SuppressWarnings("unchecked")
public ClusterUpdateSettingsRequest transientSettings(Map source) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(source);
        transientSettings(builder.string(), 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 18 with ElasticsearchGenerationException

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

the class ClusterUpdateSettingsRequest method persistentSettings.

/**
     * Sets the persistent settings to be updated. They will get applied cross restarts
     */
@SuppressWarnings("unchecked")
public ClusterUpdateSettingsRequest persistentSettings(Map source) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(source);
        persistentSettings(builder.string(), 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 19 with ElasticsearchGenerationException

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

the class CreateIndexRequest method aliases.

/**
     * Sets the aliases that will be associated with the index when it gets created
     */
@SuppressWarnings("unchecked")
public CreateIndexRequest aliases(Map source) {
    try {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.map(source);
        return aliases(builder.bytes());
    } 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 20 with ElasticsearchGenerationException

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

the class CreateIndexRequest method settings.

/**
     * The settings to create the index with (either json/yaml/properties format)
     */
@SuppressWarnings("unchecked")
public CreateIndexRequest settings(Map source) {
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
        builder.map(source);
        settings(builder.string(), XContentType.JSON);
    } catch (IOException e) {
        throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
    }
    return this;
}
Also used : IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) ElasticsearchGenerationException(org.elasticsearch.ElasticsearchGenerationException)

Aggregations

IOException (java.io.IOException)21 ElasticsearchGenerationException (org.elasticsearch.ElasticsearchGenerationException)21 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)19 UncheckedIOException (java.io.UncheckedIOException)7 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