solr 索引mysql DIH 链接

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).

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

>

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

>
type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://SERVER/DATABASE"
user="USERNAME"
password="PASSWORD"/>
name="content">
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">
column="nid" name="id" />
column="body" name="body" />
column="title" name="title" />
>

>

>

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.

>

name="responseHeader">
name="status">0>
name="QTime">0>
>


name="initArgs">

name="defaults">
name="config">data-config.xml>
>

>

name="command">full-import>
name="status">idle>
name="importResponse"/>

name="statusMessages">
name="Total Requests made to DataSource">1>
name="Total Rows Fetched">1056>
name="Total Documents Skipped">0>
name="Full Dump Started">2010-02-22 14:46:35>

name="">
Indexing completed. Added/Updated: 1056 documents. Deleted 0 documents.
>

name="Committed">2010-02-22 14:46:42>
name="Optimized">2010-02-22 14:46:42>
name="Total Documents Processed">1056>
name="Time taken ">0:0:6.562>
>


name="WARNING">
This response format is experimental. It is likely to change in the future.
>

>

				

郑重声明:本文版权包含图片归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们(delete@yzlfxy.com)修改或删除,多谢。

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

留言与评论(共有 0 条评论)
昵称:
匿名发表
   
验证码: