package test; import java.util.ArrayList; import java.util.Collection; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.common.SolrInputDocument; public class AddDocsDemo { public static final String SOLR_URL = "http://172.168.63.233:8983/solr"; public static void main(String[] args) { //通过浏览器查看结果 //http://172.168.63.233:8983/solr/collection1/select?q=name%3A%E6%94%B9%E9%9D%A9&wt=json&indent=true AddDocs(); //delDocs(); } public static void AddDocs() { String[] words = { "中央全面深化改革领导小组", "第四次会议", "审议了国企薪酬制度改革", "考试招生制度改革", "传统媒体与新媒体融合等", "相关内容文件", "×××强调要", "逐步规范国有企业收入分配秩序", "实现薪酬水平适当", "结构合理、管理规范、监督有效", "对不合理的偏高", "过高收入进行调整", "深化考试招生制度改革", "总的目标是形成分类考试", "综合评价", "多元录取的考试招生模式", "健全促进公平", "科学选才", "监督有力的体制机制", "着力打造一批形态多样", "手段先进", "具有竞争力的新型主流媒体", "建成几家拥有强大实力和传播力", "公信力", "影响力的新型媒体集团" }; HttpSolrClient solr= new HttpSolrClient.Builder("http://localhost:8983/solr/qie").build(); try { long start = System.currentTimeMillis(); Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(); for (int i = 1; i < 300; i++) { SolrInputDocument document = new SolrInputDocument(); document.addField("id", "id" + i); document.addField("name", words[i % 21]); document.addField("price", 10 * i); solr.add(document); solr.commit(); } solr.add(docs); solr.commit(); }catch(Exception $e) { } System.out.println("done!"); } public static void delDocs() { } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。