solr mysql dih_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.

>

>

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值