Solr 连接sql server 作为数据源
来源:互联网 发布:物理地址是mac地址吗 编辑:程序博客网 时间:2024/06/05 18:32
1. 下载jdbc 驱动
Download Microsoft JDBC Driver 4.0 for SQL Server from: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
copy file 'sqljdbc4.jar' to 'contrib/dataimporthandler/lib'
copy file 'sqljdbc4.jar' to 'contrib/dataimporthandler/lib'
2. 创建 core pdms
create core and below dir is ready
[plcm@pdmstest pdms]$ ll
total 4
drwxrwxr-x 3 plcm plcm 143 Oct 18 18:39 conf
-rw-rw-r-- 1 plcm plcm 74 Oct 18 17:58 core.properties
drwxrwxr-x 5 plcm plcm 56 Oct 18 17:58 data
[plcm@pdmstest pdms]$ pwd
/home/plcm/Downloads/solr-7.1.0/server/solr/pdms
[plcm@pdmstest pdms]$
3. 拷贝lib
在 /path-to/solr-6.X.X/contrib/dataimporthandler/下创建lib文件夹,拷贝lib到目录下
cp /path-to/
Progress/DataDirect/Connect_for_JDBC_51/lib/sqlserver.jar
/path-to/ solr-
6.6.0/contrib/dataimporthandler/lib/sqlserver.jar
4. 配置lib solrconfig xml
[plcm@pdmstest conf]$ vi solrconfig.xml
[plcm@pdmstest conf]$ pwd
/home/plcm/Downloads/solr-7.1.0/server/solr/configsets/_default/conf
edit solrconfig.xml by adding:
<lib dir="../../contrib/dataimporthandler/lib" regex=".*\.jar" />
<lib dir="../../dist/" regex="solr-dataimporthandler-.*\.jar" />
[plcm@pdmstest conf]$ pwd
/home/plcm/Downloads/solr-7.1.0/server/solr/configsets/_default/conf
edit solrconfig.xml by adding:
<lib dir="../../contrib/dataimporthandler/lib" regex=".*\.jar" />
<lib dir="../../dist/" regex="solr-dataimporthandler-.*\.jar" />
配置handler
Add the following configuration lines to solrconfig.xml which will instruct Solr to register the Data Import handler.
<
requestHandler
name
=
"/dataimport"
class
=
"org.apache.solr.handler.dataimport.DataImportHandler"
>
<
lst
name
=
"defaults"
>
<
str
name
=
"config"
>/path-to/solr-6.6.0/server/solr/your_corename/conf/data-config.xml</
str
>
</
lst
>
</
requestHandler
>
6. data-config.xml
create a new file data-config.xml. Add the following configuration to the file which has the details on how to connect to SQL Server using Progress DataDirect JDBC driver, which entity to get the data from specified by the query and fields that you are expecting in the query resultset.
<dataConfig> <dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://172.21.104.67:1433;database=epmdb" user="plcmuser" password="Polycom123"/> <document> <entity name="resourcefile" pk="resourceFileId" query="select resourceFileId,fileName from t1.resourcefile"> <field column="resourceFileId" name="resourceFileId"/> <field column="fileName" name="fileName"/> </entity> </document></dataConfig>
7.managed-schema.xml
Go to the path /path-to/solr-6.6.0/server/solr//conf and open the file managed-schema.xml.
Find the uniqueKey tag and change it to the primary key of the entity that you are querying on. In this case I haveresourceFileId as my primary key for the tableresorce file I am trying to fetch, so I changed the value of the tag as below.
<
uniqueKey
>resourceFileId</
uniqueKey
>
8 add field to managed-schema.xml
<field name="resourceFileId" type="string" indexed="true" stored="true" required="true" multiValued="false"/> <field name="fileName" type="string" indexed="true" stored="true" multiValued="false"/>
增加了一些基本类型定义
<fieldType name="int" class="solr.TrieIntField" docValues="true" precisionStep="0" positionIncrementGap="0"/> <fieldType name="float" class="solr.TrieFloatField" docValues="true" precisionStep="0" positionIncrementGap="0"/> <fieldType name="long" class="solr.TrieLongField" docValues="true" precisionStep="0" positionIncrementGap="0"/> <fieldType name="double" class="solr.TrieDoubleField" docValues="true" precisionStep="0" positionIncrementGap="0"/>
附件为测试成功的 配置文件,三个文件均位于conf目录下
https://github.com/hanruikai/solr
阅读全文
0 0
- Solr 连接sql server 作为数据源
- 设置数据源连接SQL SERVER
- SQL server 配置连接数据源
- Excel作为数据源和导入SQL Server碰到的问题
- SQL Server连接远程数据源的基本方法
- 操作SQL Server数据源
- 配置sql server数据源
- spark sql 使用hive作为数据源
- tomcat使用数据源和连接池技术连接Sql server数据库
- 配置SQL Server ODBC数据源
- 如何创建 SQL Server 数据源
- 使用connection对象创建SQL server和ODBC的数据源连接
- 【傻瓜式】QT5+sql server(ODBC)创建数据源并且连接数据库
- 使用mongodb作为数据源搭建solr搜索引擎之创建同步索引实现
- 添加数据源并配置数据源与sql Server身份验证模式
- 使用spring 配置数据源,并用数据源得到连接,操作sql
- 使用spring 配置数据源,并用数据源得到连接,操作sql
- tomcat的sql server数据源的配置
- solr笔记
- 设计模式之建造者模式
- 论运维人员怎么才能能好好放个长假
- 旅行家
- maven安装环境变量问题及配置到eclipse中
- Solr 连接sql server 作为数据源
- dubbo 在Spring、SpringMvc、Springboot中混合使用
- 小知识笔记
- 算法资料汇总
- iOS判断是否是移动数据上网,主要为了获取手机号一键登录
- LNMP安装目录、配置文件位置、目录文件位置
- Object doesn't support property or method 'die'
- 机器学习算法之决策树
- Webservice学习总结