Skip to content

Instantly share code, notes, and snippets.

@TimSin
Created August 5, 2013 15:09
Show Gist options
  • Save TimSin/6156670 to your computer and use it in GitHub Desktop.
Save TimSin/6156670 to your computer and use it in GitHub Desktop.
Setting elasticsearch index and mapping settings using the java API
XContentBuilder settings = // ...create settings JSON object
XContentBuilder mapping = // ...build mapping JSON object
CreateIndexRequestBuilder irb = client.admin().indices().prepareCreate(INDEX_NAME);
irb.setSettings(settings);
irb.execute().actionGet();
PutMappingResponse response = client.admin().indices()
.preparePutMapping(INDEX_NAME).setType(TYPE_NAME)
.setSource(mapping).setIndices(INDEX_NAME)
.execute().actionGet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment