1.把PostgreSQL的Jar包  例如:postgresql-9.1-901-1.jdbc4.jar  或其他版本

  放到D:\apache-tomcat-7.0.57\webapps\solr\WEB-INF\lib下

2.然后在tomcat-solr\collection1\conf下新建一个配置文件:data-config.xml,然后在本目录下编辑配置文件:solrconfig.xml

  找到很多个requestHandler节点,在最下面增加:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>

  
  <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
  <lst name="defaults">
  <str name="config">D:\apache-tomcat-7.0.57\webapps\solr\solr_home\collection1\conf\data-config.xml</str>
  </lst>
  </requestHandler>

3. 将初次下载的solr-4.10.2文件夹下的dist, contrib文件夹复制到TomCat根目录下:

  

4.然后再次修改刚才编辑过的solrconfig.xml增加两个文件夹的配置并修改一些参数:

  大约在75行默认有8个路径,但是路径不一定全对,顺着这个配置的路径去找文件夹,根据查找的层数修改这个路径配置,另增加一个新的配置,全文如下:(具体配置还要根据实际情况而定)

  <lib dir="D:\apache-tomcat\contrib\extraction\lib" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-cell-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\contrib\clustering\lib\" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-clustering-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\contrib\langid\lib\" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-langid-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\contrib\velocity\lib" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-velocity-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-dataimporthandler-\d.*\.jar" />

5. 将dist文件夹下的

  

  复制到webapps\solr\WEB-INF\lib下。

6.编辑data-config.xml,例如

<!-- db导入solr配置文件 -->
<dataConfig>
<dataSource driver="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/postgres?useUnicode=true&amp;characterEncoding=utf-8"
user="postgres" password="000000"/>
<document>
<entity name="notification" pk="ID" query="SELECT
'SLQ_Notification' AS type,
&quot;NOTIFY_ID&quot; AS indexId,
&quot;UUID&quot; AS uuid,
&quot;NOTIFY_ID&quot; AS notifyId,
&quot;NOTIFY_TYPE&quot; AS notifyType,
&quot;DIRECTION&quot; AS direction,
&quot;UID&quot; AS uid,
&quot;MSG&quot; AS msg,
&quot;REF_ID&quot; AS refId,
&quot;REF_UID&quot; AS refUid,
&quot;APPLY_UID&quot; AS applyUid,
&quot;APPLY_ID&quot; AS applyId,
&quot;REF_IMAGE_URLS&quot; AS refImageUrls,
&quot;FROM_UID&quot; AS fromUid,
&quot;LAST_UPDATE_TIME&quot; AS lastUpdateTime,
&quot;CREATE_TIME&quot; AS createTime,
&quot;IS_DELETED&quot; AS isDeleted
FROM &quot;TBL_SLQ_NOTIFICATION&quot;"/> <entity name="letter" pk="ID" query="SELECT
'SLQ_Letter' AS type,
'slq'||&quot;ID&quot; AS indexId,
&quot;DIRECTION&quot; AS direction,
&quot;MSG_BOX_TYPE&quot; AS messageBoxType,
&quot;UUID&quot; AS uuid,
&quot;MSG_TYPE&quot; AS msgType,
&quot;DURATION&quot; AS duration,
&quot;CONTENT&quot; AS msg,
&quot;AUDIO_URLS&quot; AS audioUrls,
&quot;VIDEO_URLS&quot; AS videoUrls,
&quot;IMAGE_URLS&quot; AS imageUrls,
&quot;TO_UID&quot; AS toUid,
&quot;REF_ID&quot; AS refId,
&quot;REF_UID&quot; AS refUid,
&quot;APPLY_UID&quot; AS applyUid,
&quot;SUGGEST_UID&quot; AS suggestUid,
&quot;FROM_UID&quot; AS fromUid,
&quot;CREATE_TIME&quot; AS createTime,
&quot;IS_DELETED&quot; AS isDeleted
FROM &quot;TBL_SLQ_MESSAGE&quot;"/>
</document>
</dataConfig>

7.编辑schema.xml文件   和mysql oracle一样

Solr4.7.0连接PostgreSQL的更多相关文章

  1. Solr4.7.0连接Oracle

    1.把Oracle的Jar包  例如:ojdbc14.jar  或其他版本 放到D:\apache-tomcat-7.0.57\webapps\solr\WEB-INF\lib下 2.然后在tomca ...

  2. Solr4.7.0连接MySQL

    1.把Mysql的Jar包  例如:mysql-connector-java-5.1.8-bin.jar  或其他版本 放到D:\apache-tomcat-7.0.57\webapps\solr\W ...

  3. ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库

    前段时间在园子里看到了小蝶惊鸿 发布的有关绿色版的Linux.NET——“Jws.Mono”.由于我对.Net程序跑在Linux上非常感兴趣,自己也看了一些有关mono的资料,但是一直没有时间抽出时间 ...

  4. Solr4.8.0源码分析(24)之SolrCloud的Recovery策略(五)

    Solr4.8.0源码分析(24)之SolrCloud的Recovery策略(五) 题记:关于SolrCloud的Recovery策略已经写了四篇了,这篇应该是系统介绍Recovery策略的最后一篇了 ...

  5. Solr4.8.0源码分析(14)之SolrCloud索引深入(1)

    Solr4.8.0源码分析(14) 之 SolrCloud索引深入(1) 上一章节<Solr In Action 笔记(4) 之 SolrCloud分布式索引基础>简要学习了SolrClo ...

  6. php连接postgresql

    在ubuntu下用php连接postgresql需要下个模块php5-pgsql 连接数据库并显示一张表的内容: <?php #连接数据库 $conn = pg_connect("ho ...

  7. python连接postgresql数据库

    python可以通过第三方模块连接postgresql. 比较有名的有psycopg2  和python3-postgresql (一)psycopg2 ubuntu下安装 sudo apt-get ...

  8. macOS上的ODBC-利用unixODBC连接PostgreSQL与SQLite并进行数据迁移

    安装UnixODBC & PSQLODBC driver for UnixODBC $ brew install psqlodbc Updating Homebrew... ==> In ...

  9. win7 安装用mingw编译的Qt源码并连接postgresql

    下载Qt 1.下载qt-creator-windows-opensource-2.8.0,下载路径:http://download.qt.io/official_releases/qtcreator/ ...

随机推荐

  1. java 第三周作业

    1.P132分析: long before = System.currentTimeMillis(); //返回当前的计算机时间,时间的表达格式为当前计算机时间和GMT时间(格林威治时间)1970年1 ...

  2. 高性能JavaScript(1)

    ---------------------------------------------------------------------------------------------------- ...

  3. Idea常用功能汇总

    1.格式化代码:Ctrl+Alt+L 2.重命名变量:光标停留在变量上,Shift+F6 3.打开文件或者项目所在目录: 右键>Show in Explorer 4.添加包围代码块的快捷键:Ct ...

  4. tomcat配置去掉项目名称

    在web项目中,把代码部署到服务器上访问时都不带项目名,可以配置tomcat 在tomcat安装目录下,找到conf/server.xml打开 <Host name="localhos ...

  5. JDBC 链接mysql 8 的问题

    转载:jdbc连接mysql 8 的一些坑 1.驱动包要升级为 mysql-connector-java-8.0.11.jar 2.JDBC driver 由“com.mysql.jdbc.Drive ...

  6. mac系统访问windows共享文件夹

    1. 打开finder 2. 找到前往 - 连接服务器 3. 打开后,输入smb://ip地址  点击连接 4. 选择共享文件夹 5. 点击好,之后就可以了,如下图

  7. React生命周期简单详细理解

    前言 学习React,生命周期很重要,我们了解完生命周期的各个组件,对写高性能组件会有很大的帮助. Ract生命周期 React 生命周期分为三种状态 1. 初始化 2.更新 3.销毁 初始化 1.g ...

  8. Java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind异常

    端口被占用,可能是其他程序占用,也有可能是自己代码逻辑不对,比如BZ在写SocketServer时把添加端口的代码放进了while里(sasasa.....). 查看本机端口是否被占用:netstat ...

  9. hdu 1698 (延迟标记+区间修改+区间求和)

    In the game of DotA, Pudge's meat hook is actually the most horrible thing for most of the heroes. T ...

  10. 大数据量下的SQL Server数据库自身优化

    原文: http://www.d1net.com/bigdata/news/284983.html 1.1:增加次数据文件 从SQL SERVER 2005开始,数据库不默认生成NDF数据文件,一般情 ...