solr 索引mysql DIH 链接

php中文网
发布: 2016-06-07 15:03:49
原创
1653人浏览过

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

 <span><span><requestHandler</span>
 <span>name</span>
=<span>"/dataimport"</span>
 </span>
<br />
<span>     <span>class</span>
=<span>"org.apache.solr.handler.dataimport.DataImportHandler"</span>
<span>></span>
</span>
<br />
    <span><span><lst</span>
 <span>name</span>
=<span>"defaults"</span>
<span>></span>
</span>
<br />
      <span><span><str</span>
 <span>name</span>
=<span>"config"</span>
<span>></span>
</span>
data-config.xml<span><span></str<span>></span>
</span>
</span>
<br />
    <span><span></lst<span>></span>
</span>
</span>
<br />
  <span><span></requestHandler<span>><br />
<br />
</span>
</span>
</span>
登录后复制

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

<span><span><dataConfig<span>></span>
</span>
</span>
<br />
	<span><span><dataSource</span>
 <span>type</span>
=<span>"JdbcDataSource"</span>
</span>
<br />
<span>   <span>driver</span>
=<span>"com.mysql.jdbc.Driver"</span>
</span>
<br />
<span>   <span>url</span>
=<span>"jdbc:mysql://SERVER/DATABASE"</span>
</span>
<br />
<span>   <span>user</span>
=<span>"USERNAME"</span>
 </span>
<br />
<span>   <span>password</span>
=<span>"PASSWORD"</span>
<span>/></span>
</span>
<br />
	<span><span><document</span>
 <span>name</span>
=<span>"content"</span>
<span>></span>
</span>
<br />
        <span><span><entity</span>
 <span>name</span>
=<span>"node"</span>
 <span>query</span>
=<span>"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"</span>
<span>></span>
</span>
<br />
            <span><span><field</span>
 <span>column</span>
=<span>"nid"</span>
 <span>name</span>
=<span>"id"</span>
 <span>/></span>
</span>
<br />
            <span><span><field</span>
 <span>column</span>
=<span>"body"</span>
 <span>name</span>
=<span>"body"</span>
 <span>/></span>
</span>
<br />
            <span><span><field</span>
 <span>column</span>
=<span>"title"</span>
 <span>name</span>
=<span>"title"</span>
 <span>/></span>
</span>
<br />
        <span><span></entity<span>></span>
</span>
</span>
<br />
    <span><span></document<span>></span>
</span>
</span>
<br />
<span><span></dataConfig<span>><br />
</span>
</span>
</span>
登录后复制

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.

 

BIWEB电脑商城站源码
BIWEB电脑商城站源码

BIWEB电脑商城站采用PHP5+PDO_mysql+MYSQL+SMARTY程序架构,在WINDOWS、LINUX、UNIX下均表现优异,BIWEB的链接系统使得整个网站更像纯静态网页网站,并使全站链接最大只有3层,对搜索引擎非常友好,利于搜索引擎全站收录。

BIWEB电脑商城站源码 111
查看详情 BIWEB电脑商城站源码

<span><span><response<span>></span>
</span>
</span>
<br />
 <br />
<span><span><lst</span>
 <span>name</span>
=<span>"responseHeader"</span>
<span>></span>
</span>
<br />
<span><span><int</span>
 <span>name</span>
=<span>"status"</span>
<span>></span>
</span>
0<span><span></int<span>></span>
</span>
</span>
<br />
<span><span><int</span>
 <span>name</span>
=<span>"QTime"</span>
<span>></span>
</span>
0<span><span></int<span>></span>
</span>
</span>
<br />
<span><span></lst<span>></span>
</span>
</span>
<br />
 <br />
<span><span><lst</span>
 <span>name</span>
=<span>"initArgs"</span>
<span>></span>
</span>
<br />
 <br />
<span><span><lst</span>
 <span>name</span>
=<span>"defaults"</span>
<span>></span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"config"</span>
<span>></span>
</span>
data-config.xml<span><span></str<span>></span>
</span>
</span>
<br />
<span><span></lst<span>></span>
</span>
</span>
<br />
<span><span></lst<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"command"</span>
<span>></span>
</span>
full-import<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"status"</span>
<span>></span>
</span>
idle<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"importResponse"</span>
<span>/></span>
</span>
<br />
 <br />
<span><span><lst</span>
 <span>name</span>
=<span>"statusMessages"</span>
<span>></span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Total Requests made to DataSource"</span>
<span>></span>
</span>
1<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Total Rows Fetched"</span>
<span>></span>
</span>
1056<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Total Documents Skipped"</span>
<span>></span>
</span>
0<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Full Dump Started"</span>
<span>></span>
</span>
2010-02-22 14:46:35<span><span></str<span>></span>
</span>
</span>
<br />
 <br />
<span><span><str</span>
 <span>name</span>
=<span>""</span>
<span>></span>
</span>
<br />
Indexing completed. Added/Updated: 1056 documents. Deleted 0 documents.<br />
<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Committed"</span>
<span>></span>
</span>
2010-02-22 14:46:42<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Optimized"</span>
<span>></span>
</span>
2010-02-22 14:46:42<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Total Documents Processed"</span>
<span>></span>
</span>
1056<span><span></str<span>></span>
</span>
</span>
<br />
<span><span><str</span>
 <span>name</span>
=<span>"Time taken "</span>
<span>></span>
</span>
0:0:6.562<span><span></str<span>></span>
</span>
</span>
<br />
<span><span></lst<span>></span>
</span>
</span>
<br />
 <br />
<span><span><str</span>
 <span>name</span>
=<span>"WARNING"</span>
<span>></span>
</span>
<br />
This response format is experimental.  It is likely to change in the future.<br />
<span><span></str<span>></span>
</span>
</span>
<br />
<span><span></response<span>></span>
</span>
</span>
登录后复制

登录后复制
登录后复制
相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号