Solr 4.4.0利用dataimporthandler导入postgresql数据库表
将数据库edbstore的edbtore schema下的customers表导入到solr
1. 首先查看customers表字段信息
edbstore=> \d customers
Table "edbstore.customers"
Column | Type | Modifiers
----------------------+-----------------------+----------------------------------------------------------------
customerid | integer | not null default nextval('customers_customerid_seq'::regclass)
firstname | character varying(50) | not null
lastname | character varying(50) | not null
address1 | character varying(50) | not null
address2 | character varying(50) |
city | character varying(50) | not null
state | character varying(50) |
zip | integer |
country | character varying(50) | not null
region | smallint | not null
email | character varying(50) |
phone | character varying(50) |
creditcardtype | integer | not null
creditcard | character varying(50) | not null
creditcardexpiration | character varying(50) | not null
username | character varying(50) | not null
password | character varying(50) | not null
age | smallint |
income | integer |
gender | character varying(1) |
2. 新建core,名称为edbstore

3. 修改solrconfig.xml文件,添加如下
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
4. 新建data-config.xml文件,内容如下所示
<dataConfig>
<dataSource name="source1" type="JdbcDataSource" driver="org.postgresql.Driver" url="jdbc:postgresql://172.16.101.66:5432/edbstore" user="edbstore" password="edbstore" />
<document>
<entity name="file1" datasource="source1" query="SELECT * FROM edbstore.customers">
<field column="customerid" name="id" />
<field column="firstname" name="firstname" />
<field column="lastname" name="lastname" />
<field column="address1" name="address1" />
<field column="address2" name="address2" />
<field column="city" name="city" />
<field column="state" name="state" />
<field column="zip" name="zip" />
<field column="country" name="country" />
<field column="region" name="region" />
<field column="email" name="email" />
<field column="phone" name="phone" />
<field column="creditcardtype" name="creditcardtype" />
<field column="creditcard" name="creditcard" />
<field column="creditcardexpiration" name="creditcardexpiration" />
<field column="username" name="username" />
<field column="password" name="password" />
<field column="age" name="age" />
<field column="income" name="income" />
<field column="gender" name="gender" />
</entity>
</document>
</dataConfig>
5. 将以下信息添加到schema.xml文件
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> -->
<field name="firstname" type="string" indexed="true" stored="true" />
<field name="lastname" type="string" indexed="true" stored="true" />
<field name="address1" type="string" indexed="true" stored="true" />
<field name="address2" type="string" indexed="true" stored="true" />
<field name="city" type="string" indexed="true" stored="true" />
<field name="state" type="string" indexed="true" stored="true" />
<field name="zip" type="int" indexed="true" stored="true" />
<field name="country" type="string" indexed="true" stored="true" />
<field name="region" type="int" indexed="true" stored="true" />
<field name="email" type="string" indexed="true" stored="true" />
<field name="phone" type="string" indexed="true" stored="true" />
<field name="creditcardtype" type="int" indexed="true" stored="true" />
<field name="creditcard" type="string" indexed="true" stored="true" />
<field name="creditcardexpiration" type="string" indexed="true" stored="true" />
<field name="username" type="string" indexed="true" stored="true" />
<field name="password" type="string" indexed="true" stored="true" />
<field name="age" type="int" indexed="true" stored="true" />
<field name="income" type="int" indexed="true" stored="true" />
<field name="gender" type="string" indexed="true" stored="true" />
6. 下载postgresql jdbc驱动
https://jdbc.postgresql.org/download.html
注意版本要和本地的JDK版本兼容
将驱动文件postgresql-42.2.6.jre6.jar复制到tomcat的solr lib目录,重启tomcat
7. 执行DIH导入

8. 查看导入的document

Solr 4.4.0利用dataimporthandler导入postgresql数据库表的更多相关文章
- Solr 4.4.0利用dataimporthandler导入本地pdf、word等文档
1. 创建本地目录 $ mkdir /usr/local/contentplatform/solr/solr/core1/file1 $ ls -lh total 88M -rw-r--r-- tnu ...
- 利用DBExportDoc V1.0 For MySQL自动生成数据库表结构文档
对于DBA或开发来说,如何规范化你的数据库表结构文档是灰常之重要的一件事情.但是当你的库,你的表排山倒海滴多的时候,你就会很头疼了. 推荐一款工具DBExportDoc V1.0 For MySQL( ...
- 【工具篇】利用DBExportDoc V1.0 For MySQL自动生成数据库表结构文档
对于DBA或开发来说,如何规范化你的数据库表结构文档是灰常之重要的一件事情.但是当你的库,你的表排山倒海滴多的时候,你就会很头疼了. 推荐一款工具DBExportDoc V1.0 For MySQL( ...
- jsp+servlet上传excel并将数据导入到数据库表的实现方法
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- 在Linux环境下,将Solr部署到tomcat7中,导入Mysql数据库数据, 定时更新索引
什么是solr solr是基于Lucene的全文搜索服务器,对Lucene进行了扩展优化. 准备工作 首先,去下载以下软件包: JDK8:jdk-8u60-linux-x64.tar.gz TOMCA ...
- TPC-H生成.tbl文件导入postgresql数据库的坑
数据库project好好的不用主流的MySQL和Microsoft server而要求用听都没听过的postgresql (当然,可能你三个都没听过) 这里的坑主要是把生成的那八张.tbl的表导入pg ...
- mybatis使用注解往postgresql数据库表insert数据[主键自增]的写法
建表SQL: DROP TABLE IF EXISTS person; CREATE TABLE person( person_id serial PRIMARY KEY NOT NULL, pers ...
- [转]使用Navicat导入导出数据库表
原文地址:https://blog.csdn.net/anselandevil/article/details/81667199 步骤1:数据中原始数据如下: 点击表,右键选择导出向导,选择导出为sq ...
- python2/3 利用psycopg2 连接postgreSQL数据库。
psycopg2 是一个通过python连接postgreSQL的库, 不要被它的名称蒙蔽了,你可能发现它的版本是psyconpg2.7.*, 以为它只能在python2上使用,实际上,这只是一个巧合 ...
随机推荐
- 自定义 Swiper 的pageControl
.part5-bg .swiper2 .swiper-pagination2{ bottom: 0.4rem; } /*未选中的小圆点样式*/ .part5-bg .swiper2 .swiper-p ...
- Qt修改图片的背景色及设置背景色为透明的方法
先上干货. Qt下修改图片背景色的方法: 方法一: QPixmap CKnitWidget::ChangeImageColor(QPixmap sourcePixmap, QColor origCol ...
- 游戏2048的python实现
前些日子被问了一下2048是如何实现,说实话当时没有想的特别清晰,所以回答的也比较混乱,后来仔细想想这个问题还是挺有趣的,简单的实现了一下 这个问题里面主要有两个问题,一个是移动时的计算,二是移动前对 ...
- spring aop 实现controller 日志
@Aspect @Component @Slf4j public class ControllerAspact { @Pointcut("execution(public * com.exa ...
- java 判断Map集合中包含指定的键名,则返回true,否则返回false。
public static void main(String[] args) { Map map = new HashMap(); //定义Map对象 map.put("apple" ...
- 关于MySQL中查询结果的count和from后的条件与where后的条件对比
啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 ...
- extentsreport testng美化报告生成
一:主要内容 优化testng测试报告,使用extentsreport 解决extentsreport打开后加载不出来样式的问题 二:报告效果 先上图,看下testng extentsreport报告 ...
- TensorFlow常用操作
初始化数据: # -*- coding: utf-8 -*- import tensorflow as tf a = tf.zeros([3, 4], tf.int32) # [[0 0 0 0] # ...
- 使用DBLink方式同步远程数据库中含Blob、Clob字段表的问题解决
在数据库同步中我们经常会用到DBLink方式.DBLink可以将物理上存放于网络的多个数据库在逻辑上当成一个单一的大数据库.开发人员无需关心数据库的网络分布,就能很方便的实现从不同数据库之间读取数据. ...
- Linux修改环境变量的4种方法
转载 查看PATH:echo $PATH以添加mongodb server为列修改方法一:export PATH=/usr/local/mongodb/bin:$PATH//配置完后可以通过echo ...