This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress( | |
"localhost", 9300)); | |
XContentBuilder mapping = XContentFactory.jsonBuilder() | |
.startObject() | |
.startObject("mappings") | |
.startObject("testobject") | |
.startObject("properties") | |
.startObject("key") | |
.field("type", "string") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |