-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexMapping.java
More file actions
22 lines (21 loc) · 899 Bytes
/
IndexMapping.java
File metadata and controls
22 lines (21 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress("HOST1", 9300))
.addTransportAddress(new InetSocketTransportAddress("HOST2", 9300));
//Client client = NodeBuilder.nodeBuilder().client(true).node().client();
client.admin().indices().prepareCreate(INDEX).execute().actionGet();
XContentBuilder builder = XContentFactory.jsonBuilder().
startObject().
startObject(DOCUMENT_TYPE).
startObject("properties").
startObject("path").
field("type", "string").field("store", "yes").field("index", "not_analyzed").
endObject().
startObject("title").
field("type", "string").field("store", "yes").field("analyzer", "german").
endObject().
// more mapping
endObject().
endObject().
endObject();
client.admin().indices().preparePutMapping(index).setType(DOCUMENT_TYPE).setSource(builder).execute().actionGet();
client.close();