对于elasticsearch,我是否可以使用示例代码将属性分配给索引字段(如在solr中的config.xml中)。用于加载属性文件的Java API代码示例。
Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.sniff", true).build();
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
List<XYZ> list = xyz.getObj("5");
ObjectMapper mapper = new ObjectMapper();
for(Object obj : list){
try {
String json = mapper.writeValueAsString(obj);
System.out.println(json);
//I want a code here to load the mapping file and syntax for mapping file,
through which i can say that only few attributes of this object should be indexed and rest all to be stored..//
IndexRequestBuilder indexRequestBuilder = client.prepareIndex("searchindex", "searchtype", obj.getId());
indexRequestBuilder.setSource(json);
indexRequestBuilder.execute().actionGet();