我想在Solr中为数据库(MySQL)编制索引.数据库只有一个表,但是它有50列和近400万行.大约1.5GB.
我配置了solrconfig.xlm,solr-data-config.xml,并在schema.xml中添加了:
<dynamicField name="*" type="text_general" multiValued="false" indexed="true" stored="true" />
因为每个字段都是文本.
当我尝试导入数据时,需要花费几秒钟的时间,并且什么也没有发生.我有
Requests: 1, Fetched: 0, Skipped: 0, Processed: 0
日志中有错误:
java.sql.SQLException: Unexpected exception encountered during query.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2866) at
com.mysql.jdbc.ConnectionImpl.rollbackNoChecks(ConnectionImpl.java:5191)
at com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:5074)
at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4667)
at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1640) at
org.apache.solr.handler.dataimport.JdbcDataSource.closeConnection(JdbcDataSource.java:484)
at
org.apache.solr.handler.dataimport.JdbcDataSource.close(JdbcDataSource.java:469)
at
org.apache.solr.handler.dataimport.DocBuilder.closeEntityProcessorWrappers(DocBuilder.java:288)
at
org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:277)
at
org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:416)
at
org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:480)
at
org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:461)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at
com.mysql.jdbc.Buffer.readFieldLength(Buffer.java:289) at
com.mysql.jdbc.Buffer.fastSkipLenString(Buffer.java:170) at
com.mysql.jdbc.MysqlIO.unpackField(MysqlIO.java:708) at
com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:428) at
com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3222)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2393) at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2816) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2820) …
11 more
我已经尝试过使用小型数据库,并且可以正常工作,每个字段都已建立索引.我只有大基础才有问题.
我将solrconfig.xlm中的ramBufferSizeMB和maxBufferedDocs更改为2GB和4GB,但这无济于事.我不知道怎么了
解决方法:
尝试使用其他batchSize设置.
DataImportHandler is designed to stream row one-by-one. It passes a fetch size value (default: 500) to Statement#setFetchSize which some drivers do not honor. For MySQL, add batchSize property to dataSource configuration with value -1. This will pass Integer.MIN_VALUE to the driver as the fetch size and keep it from going out of memory for large tables.