2014年8月1日 星期五

Submit a doc to a solr cloud

This post gives an example to submit a doc to a solr cloud.

String ZookeeperQuorum="192.168.10.1",192.168.10.2,192.168.10.3";
CloudSolrServer server=new CloudSolrServer(ZookeeperQuorum);
server.setDefaultCollection("yourCollection");
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id","111");
doc.addField("intfield",100);
doc.addField("StringField","some data");
server.connect();
server.add(doc);
server.commit();

Then, a doc with id=111 will be created, and in that doc we will see "intfield"=100 and "StringField"="some data".

沒有留言:

張貼留言