首页 / SOLR / solr索引mysqlDIH链接
solr索引mysqlDIH链接
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了solr索引mysqlDIH链接,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3024字,纯文字阅读大概需要5分钟。
内容图文
![solr索引mysqlDIH链接](/upload/InfoBanner/zyjiaocheng/536/2845c0b4ec39445a9d02b67822b90138.jpg)
Download the JDBC Driver Download the JDBC Driver for MySQL from http://mysql.spd.co.il/Downloads/Connector-J/mysql-connector-java-3.1.14.zip Put the mysql-connector-java-3.1.14-bin.jar in Solr Dir/example/lib Configuring Solr to Use MySQL
Download the JDBC Driver
Download the JDBC Driver for MySQL from http://mysql.spd.co.il/Downloads/Connector-J/mysql-connector-java-3.1.14.zip
Put the "mysql-connector-java-3.1.14-bin.jar" in
Solr Dir/example/lib
Configuring Solr to Use MySQL
Solr can be configured to connect to a MySQL Data base using the DataImportHandler. To do so first in
solrconfig.xml
(This file would be in
Solr Dir/example/conf
) add a new requestHandler which is handled by DIH (DataImportHandler).
<requestHandler name ="/dataimport"
class ="org.apache.solr.handler.dataimport.DataImportHandler" >
<lst name ="defaults" >
<str name ="config" > data-config.xml</str>
</lst>
</requestHandler>
Create a new file called data-config.xml in the same directory and configure the database connection and table schema to reflect your database structure.
Sample data-config.xml
<dataConfig>
<dataSource type ="JdbcDataSource"
driver ="com.mysql.jdbc.Driver"
url ="jdbc:mysql://SERVER/DATABASE"
user ="USERNAME"
password ="PASSWORD" />
<document name ="content" >
<entity name ="node" query ="select node.nid AS nid,node_revisions.body AS body,node_revisions.title AS title from node,node_revisions where node.status = 1 and node.nid = node_revisions.nid and node.vid = node_revisions.vid" >
<field column ="nid" name ="id" />
<field column ="body" name ="body" />
<field column ="title" name ="title" />
</entity>
</document>
</dataConfig>
The dataSource configuration attributes , query in entity tag and database fields must be modified to match your database structure. The Query given in the example is a simple Join of the drupal node and node revisions tables.
Now restart or start ApacheSolr using java -jar start.jar .
Hit the full-commit url (http://SERVER:PORT/solr/dataimport?command=full-import) and your website would start getting indexed.
<response>
<lst name ="responseHeader" >
<int name ="status" > 0</int>
<int name ="QTime" > 0</int>
</lst>
<lst name ="initArgs" >
<lst name ="defaults" >
<str name ="config" > data-config.xml</str>
</lst>
</lst>
<str name ="command" > full-import</str>
<str name ="status" > idle</str>
<str name ="importResponse" />
<lst name ="statusMessages" >
<str name ="Total Requests made to DataSource" > 1</str>
<str name ="Total Rows Fetched" > 1056</str>
<str name ="Total Documents Skipped" > 0</str>
<str name ="Full Dump Started" > 2010-02-22 14:46:35</str>
<str name ="" >
Indexing completed. Added/Updated: 1056 documents. Deleted 0 documents.
</str>
<str name ="Committed" > 2010-02-22 14:46:42</str>
<str name ="Optimized" > 2010-02-22 14:46:42</str>
<str name ="Total Documents Processed" > 1056</str>
<str name ="Time taken " > 0:0:6.562</str>
</lst>
<str name ="WARNING" >
This response format is experimental. It is likely to change in the future.
</str>
</response>
内容总结
以上是互联网集市为您收集整理的solr索引mysqlDIH链接全部内容,希望文章能够帮你解决solr索引mysqlDIH链接所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。