Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Can i have a sample code for assigning the properties to index fields (as in config.xml in case of solr), for elasticsearch. Java API code sample for loading the property file, as well.

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();
share|improve this question
 
post your code , so far.. –  BGS Dec 20 '13 at 12:37
 
Can you go through and provide any help.. I have edited my post.. –  naw Dec 23 '13 at 9:49
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.