solr dih mysql 注意事项
1、当import大数据时,记住设置 batchSize="-1"。
<dataSource name="sourcename" driver="com.mysql.jdbc.Driver" batchSize="-1" url="jdbc:mysql://localhost/dbname?useUnicode=yes&char acterEncoding=UTF-8" user="username" password="password" />
2、最好将mysql所有涉及编码的地方都设置为UTF8。
3、将solrconfig.xml 中的autoCommit打开,默认未必是打开的。
4、多表联合的时候注意列名的覆盖问题,比如主表有一个外键user字段是users表的主键,若想引用users表中的name,则不可再使用user。
5、在solr默认的测试环境中,batchSize、autoCommit等参数均无效,需要将solr部署到tomcat下
附完整的db-data-configure.xml
<dataConfig> <dataSource name="sourcename" driver="com.mysql.jdbc.Driver" batchSize="-1" autoCommit="true" url="jdbc:mysql://localhost/weibo?useUnicode=yes&characterEncoding=UTF-8" user="user" password="passwd" /> <document> <entity name="msg" dataSource="weibo" pk="mid" query="select * from message" deltaImportQuery="select * from message where mid='${dih.delta.mid}'" deltaQuery="select mid from solrmonitor where last_modified > '${dih.last_index_time}'"> <field column="mid" name="mid" /> <field column="text" name="text" /> <field column="favorited" name="favorited" /> <field column="comments" name="comments" /> <field column="popularity" name="popularity" /> <field column="attitudes" name="attitudes" /> <field column="content" name="content" /> <entity name="usr" query="select name from user where id='${msg.user}'"> <field name="username" column="name" /> </entity> </entity> </document> </dataConfig>
浙公网安备 33010602011771号