将MySQL中的数据导入到solr索引库
利用solrJ向索引库导入数据
- public class SearchItem implements Serializable{
- private String id;
- private String title;
- private String sell_point;
- private long price;
- private String image;
- private String category_name;
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getSell_point() {
- return sell_point;
- }
- public void setSell_point(String sell_point) {
- this.sell_point = sell_point;
- }
- public long getPrice() {
- return price;
- }
- public void setPrice(long price) {
- this.price = price;
- }
- public String getImage() {
- return image;
- }
- public String[] getImages() {
- if(image != null && !"".equals(image)) {
- String[] images = image.split(",");
- return images;
- }
- return null;
- }
- public void setImage(String image) {
- this.image = image;
- }
- public String getCategory_name() {
- return category_name;
- }
- public void setCategory_name(String category_name) {
- this.category_name = category_name;
- }
- public SearchItem(String id, String title, String sell_point, long price, String image, String category_name) {
- super();
- this.id = id;
- this.title = title;
- this.sell_point = sell_point;
- this.price = price;
- this.image = image;
- this.category_name = category_name;
- }
- public SearchItem() {
- super();
- // TODO Auto-generated constructor stub
- }
- @Override
- public String toString() {
- return "SearchItem [id=" + id + ", title=" + title + ", sell_point=" + sell_point + ", price=" + price
- + ", image=" + image + ", category_name=" + category_name + "]";
- }
- List<SearchItem> selectAllItem();
- <select id="selectAllItem" resultType="com.e3mall.search.SearchItem">
- SELECT
- a.id,
- a.title,
- a.sell_point,
- a.price,
- a.image,
- b.`name` category_name
- FROM
- tb_item a
- LEFT JOIN tb_item_cat b ON a.cid = b.id
- WHERE a.`status`=1
- </select>
- </mapper>
- /**
- * 向索引库添加数据
- */
- public E3Result saveSearch(){
- try {
- //从数据库中查询数据
- List<SearchItem> selectAllItem = searchMapper.selectAllItem();
- for (SearchItem searchItem : selectAllItem) {
- // 创建一个文档对象SolrInputDocument
- SolrInputDocument document = new SolrInputDocument();
- // 向文档对象中添加域,文档中必须包含一个id域,所有的域的名称必须在schema.xml中定义
- document.addField("id", searchItem.getId());
- document.addField("item_title", searchItem.getTitle());
- document.addField("item_sell_point", searchItem.getSell_point());
- document.addField("item_price", searchItem.getPrice());
- document.addField("item_image", searchItem.getImage());
- document.addField("item_category_name", searchItem.getCategory_name());
- // 把文档写入索引库
- solrServer.add(document);
- }
- // 提交
- solrServer.commit();
- //返回成功
- return E3Result.ok();
- } catch (Exception e) {
- // TODO: handle exception
- return E3Result.build(500, "导入失败!");
- }
- }
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
R常用包分类
1、聚类 var a = 12.toInt; 常用的包: fpc,cluster,pvclust,mclust 基于划分的方法: kmeans, pam, pamk, clara 基于层次的方法: hclust, pvclust, agnes, diana 基于模型的方法: mclust 基于密度的方法: dbscan 基于画图的方法: plotcluster, plot.hclust 基于验证的方法: cluster.stats 2、分类 常用的包: rpart,party,randomForest,rpartOrdinal,tree,marginTree, maptree,survival 决策树: rpart, ctree 随机森林: cforest, randomForest 回归, Logistic回归, Poisson回归: glm, predict, residuals 生存分析: survfit, survdiff, coxph 3、关联规则与频繁项集 常用的包: arules:支持挖掘频繁项集,最大频繁项集,频繁闭项目集和关联规则 DRM:回归和分类数据的重复关联模型...
- 下一篇
Java小白进阶笔记(2)-变量和数据类型
复习Java知识,主要是一边看偏头痛杨的博客,一边完成博主布置的任务。这是看2.偏头痛杨的Java入门教学系列之变量&数据类型篇 的作业: 1.Java有多少种数据类型,数据类型的分类? 两种数据类型: 基本数据类型 引用数据类型除了八种基本数据类型,其他的都是引用数据类型。 2.Java的工作机制? Java程序的源代码(.java)编译成虚拟机(JVM)能看懂的字节码(.class),然后再由虚拟机解释执行成对应的操作系统能看懂的机器码 3.自动类型转换与强制类型转换的规则? 从小到大自动转 从大到小强制转 自动类型转换: byte->short->int->long->float->double char->int->long->float->double 表达式类型的自动提升: 当表达式中有多个数据类型运算式,自动提升为容量最大的数据类型。 byte,short,char之间不会自动转换,首先都提升为int 整个表达式的类型自动提升到与表达式中最高等级操作数同样的类型 强制类型转换: 容量大的数据类型转换为容量小的数...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS关闭SELinux安全模块
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- Windows10,CentOS7,CentOS8安装MongoDB4.0.16
- Hadoop3单机部署,实现最简伪集群
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- CentOS6,CentOS7官方镜像安装Oracle11G
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- SpringBoot2全家桶,快速入门学习开发网站教程
- CentOS8编译安装MySQL8.0.19
- CentOS6,7,8上安装Nginx,支持https2.0的开启