use of org.elasticsearch.ElasticsearchGenerationException in project elasticsearch by elastic.
the class PutIndexTemplateRequest method settings.
/**
* The settings to create the index template with (either json or yaml format).
*/
public PutIndexTemplateRequest settings(Map<String, Object> 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;
}
use of org.elasticsearch.ElasticsearchGenerationException in project elasticsearch by elastic.
the class PutIndexTemplateRequest method mapping.
/**
* Adds mapping that will be added when the index gets created.
*
* @param type The mapping type
* @param source The mapping source
*/
public PutIndexTemplateRequest mapping(String type, Map<String, Object> source) {
// wrap it in a type map if its not
if (source.size() != 1 || !source.containsKey(type)) {
source = MapBuilder.<String, Object>newMapBuilder().put(type, source).map();
}
try {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
return mapping(type, builder);
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
}
}
use of org.elasticsearch.ElasticsearchGenerationException in project elasticsearch by elastic.
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(builder.string(), builder.contentType());
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
}
return this;
}
use of org.elasticsearch.ElasticsearchGenerationException in project elasticsearch by elastic.
the class RestoreSnapshotRequest method settings.
/**
* Sets repository-specific restore settings
* <p>
* See repository documentation for more information.
*
* @param source repository-specific snapshot settings
* @return this request
*/
public RestoreSnapshotRequest settings(Map<String, Object> source) {
try {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
settings(builder.string(), builder.contentType());
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e);
}
return this;
}
use of org.elasticsearch.ElasticsearchGenerationException in project elasticsearch by elastic.
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(builder.string(), XContentType.JSON);
} catch (IOException e) {
throw new ElasticsearchGenerationException("Failed to generate [" + mappingSource + "]", e);
}
}
Aggregations