Skip to content

Instantly share code, notes, and snippets.

View dggc's full-sized avatar

Daniel Galinkin dggc

View GitHub Profile
{
"indices": {
"memory": {
"index_buffer_size": "30%"
}
},
"index":{
"number_of_replicas":0,
"number_of_shards":10,
"translog": {
@dggc
dggc / mapping creation
Created September 11, 2013 13:15
Code to create the mappings in Java
client.admin().indices().prepareCreate(source.toString().toLowerCase()).execute().actionGet();
XContentBuilder xbMapping = XContentFactory.jsonBuilder().startObject().startObject("documents");
xbMapping.startObject(ELASTIC_TTL).field("enabled", true).field("default", (30*60*1000)+"ms").endObject();
xbMapping.startObject("properties");
xbMapping.startObject("content").field("type", "string").endObject();
xbMapping.startObject("insertedDate").field("type", "long").endObject();
xbMapping.endObject();
xbMapping.endObject().endObject();
client.admin().indices().preparePutMapping("documents").setType("documents").setSource(xbMapping).execute().actionGet();