温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

soloJ 测试代码

发布时间:2020-07-09 11:19:02 阅读:470 作者:dfwasds 栏目:开发技术
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>
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() {
		
	}
}

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×