无法使用 dataimporthandler import/index 数据库中的 mysql 数据到 solr
Can not import/index data from mysql database to solr using dataimporthandler
I am trying to import database table from my mysql database to solr Index
through Dataimporthandler.
I have configured all needed files as below:
Data-config.xml
`<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:81/indcat"
user="root"
password=""/>
<document>
<entity name="enewtheses"
pk="inf_control_no"
query="select * from enewtheses">
<field column="inf_control_no" name="inf_control_no"/>
<field column="location" name="location"/>
<field column="date_of_entry" name="date_of_entry"/>
<field column="language" name="language"/>
<field column="physical_medium" name="physical_medium"/>
<field column="type_of_material" name="type_of_material"/>
<field column="document_number" name="document_number"/>
<field column="title" name="title"/>
<field column="parallel_title" name="parallel_title"/>
<field column="other_title" name="other_title"/>
<field column="name_of_researcher" name="name_of_researcher"/>
<field column="name_of_guide" name="name_of_guide"/>
<field column="name_of_corporate_body" name="name_of_corporate_body"/>
<field column="place_and_publisher" name="place_and_publisher"/>
<field column="date_of_publication" name="date_of_publication"/>
<field column="date_related_to_thesis_diss"
name="date_related_to_thesis_diss"/>
<field column="physical_description" name="physical_description"/>
<field column="note" name="note"/>
<field column="abstract" name="abstract"/>
<field column="class_scheme_notation" name="class_scheme_notation"/>
<field column="subject_descriptor" name="subject_descriptor"/>
<field column="reserved_for_thesis_diss" name="reserved_for_thesis_diss"/>
<field column="accession_number" name="accession_number"/>
<field column="uri" name="uri"/>
<field column="flag" name="flag"/>
<field column="bibliographical_note" name="bibliographical_note"/>
<field column="last_updated_date" name="last_updated_date"/>
<field column="last_updated_by" name="last_updated_by"/>
<field column="prepared_by" name="prepared_by"/>
<field column="bulk" name="bulk"/>
</entity>
</document>
</dataConfig>`
当我 运行 完全导入时,我在记录时遇到错误:
处理时出现异常:enewtheses 文档:SolrInputDocument(字段:
[]):org.apache.solr.handler.dataimport.DataImportHandlerException: 无法
执行查询:select * from enewtheses Processing Document # 1
数据配置文件很好我已经检查了 1000 次,在这里找不到真正的问题,完整的堆栈打印如下:
at org.apache.solr.handler.dataimport.DocBuilder.execute
(DocBuilder.java:270)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport
(DataImporter.java:415)
at org.apache.solr.handler.dataimport.DataImporter.runCmd
(DataImporter.java:474)
at org.apache.solr.handler.dataimport.DataImporter.lambda$runAsync[=13=]
(DataImporter.java:457)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException:
org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to
execute query: select * from enewtheses Processing Document # 1
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument
(DocBuilder.java:416)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump
(DocBuilder.java:329)
at org.apache.solr.handler.dataimport.DocBuilder.execute
(DocBuilder.java:232)
... 4 more
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException:
Unable to execute query: select * from enewtheses Processing Document # 1
atorg.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow
(DataImportHandlerException.java:69)
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.
<init>(JdbcDataSource.java:327)
at org.apache.solr.handler.dataimport.JdbcDataSource.createResultSetIterator
(JdbcDataSource.java:288)
at org.apache.solr.handler.dataimport.JdbcDataSource.getData
(JdbcDataSource.java:283)
at org.apache.solr.handler.dataimport.JdbcDataSource.getData
(JdbcDataSource.java:52)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery
(SqlEntityProcessor.java:59)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow
(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow
(EntityProcessorWrapper.java:267)
atorg.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.jav
a:475)
at
org.apache.solr.handler.dataimport.DocBuilder.buildDocument
(DocBuilder.java:41)
... 6 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The
driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:632)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1016)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2198)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2229)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2024)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
atcom.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
atorg.apache.solr.handler.dataimport.JdbcDataSource.call(JdbcDataSource.ja
va:192)
atorg.apache.solr.handler.dataimport.JdbcDataSource.call(JdbcDataSource.ja
va:172)
atorg.apache.solr.handler.dataimport.JdbcDataSource.getConnection(JdbcDataSo
urce.java:528)
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.
<init>(JdbcDataSource.java:317)
... 14 more
Caused by: java.io.EOFException: Can not read response from server. Expected
to
read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3011)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:567)
... 31 more
你的DIH没有问题。确保您的数据库连接字符串有效并且您的数据库已启动且 运行。
正如 Eric Wang 指出的那样,我使用了错误的端口号,之后我也收到了 SSL 证书错误,最终对我有用的 url 字符串是:
url="jdbc:mysql://127.0.0.1:3306/indcat?useSSL=false&"
I am trying to import database table from my mysql database to solr Index
through Dataimporthandler.
I have configured all needed files as below:
Data-config.xml
`<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:81/indcat"
user="root"
password=""/>
<document>
<entity name="enewtheses"
pk="inf_control_no"
query="select * from enewtheses">
<field column="inf_control_no" name="inf_control_no"/>
<field column="location" name="location"/>
<field column="date_of_entry" name="date_of_entry"/>
<field column="language" name="language"/>
<field column="physical_medium" name="physical_medium"/>
<field column="type_of_material" name="type_of_material"/>
<field column="document_number" name="document_number"/>
<field column="title" name="title"/>
<field column="parallel_title" name="parallel_title"/>
<field column="other_title" name="other_title"/>
<field column="name_of_researcher" name="name_of_researcher"/>
<field column="name_of_guide" name="name_of_guide"/>
<field column="name_of_corporate_body" name="name_of_corporate_body"/>
<field column="place_and_publisher" name="place_and_publisher"/>
<field column="date_of_publication" name="date_of_publication"/>
<field column="date_related_to_thesis_diss"
name="date_related_to_thesis_diss"/>
<field column="physical_description" name="physical_description"/>
<field column="note" name="note"/>
<field column="abstract" name="abstract"/>
<field column="class_scheme_notation" name="class_scheme_notation"/>
<field column="subject_descriptor" name="subject_descriptor"/>
<field column="reserved_for_thesis_diss" name="reserved_for_thesis_diss"/>
<field column="accession_number" name="accession_number"/>
<field column="uri" name="uri"/>
<field column="flag" name="flag"/>
<field column="bibliographical_note" name="bibliographical_note"/>
<field column="last_updated_date" name="last_updated_date"/>
<field column="last_updated_by" name="last_updated_by"/>
<field column="prepared_by" name="prepared_by"/>
<field column="bulk" name="bulk"/>
</entity>
</document>
</dataConfig>`
当我 运行 完全导入时,我在记录时遇到错误:
处理时出现异常:enewtheses 文档:SolrInputDocument(字段:
[]):org.apache.solr.handler.dataimport.DataImportHandlerException: 无法
执行查询:select * from enewtheses Processing Document # 1
数据配置文件很好我已经检查了 1000 次,在这里找不到真正的问题,完整的堆栈打印如下:
at org.apache.solr.handler.dataimport.DocBuilder.execute
(DocBuilder.java:270)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport
(DataImporter.java:415)
at org.apache.solr.handler.dataimport.DataImporter.runCmd
(DataImporter.java:474)
at org.apache.solr.handler.dataimport.DataImporter.lambda$runAsync[=13=]
(DataImporter.java:457)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException:
org.apache.solr.handler.dataimport.DataImportHandlerException: Unable to
execute query: select * from enewtheses Processing Document # 1
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument
(DocBuilder.java:416)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump
(DocBuilder.java:329)
at org.apache.solr.handler.dataimport.DocBuilder.execute
(DocBuilder.java:232)
... 4 more
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException:
Unable to execute query: select * from enewtheses Processing Document # 1
atorg.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow
(DataImportHandlerException.java:69)
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.
<init>(JdbcDataSource.java:327)
at org.apache.solr.handler.dataimport.JdbcDataSource.createResultSetIterator
(JdbcDataSource.java:288)
at org.apache.solr.handler.dataimport.JdbcDataSource.getData
(JdbcDataSource.java:283)
at org.apache.solr.handler.dataimport.JdbcDataSource.getData
(JdbcDataSource.java:52)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery
(SqlEntityProcessor.java:59)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow
(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow
(EntityProcessorWrapper.java:267)
atorg.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.jav
a:475)
at
org.apache.solr.handler.dataimport.DocBuilder.buildDocument
(DocBuilder.java:41)
... 6 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The
driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:989)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:632)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1016)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2198)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2229)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2024)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
atcom.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
atorg.apache.solr.handler.dataimport.JdbcDataSource.call(JdbcDataSource.ja
va:192)
atorg.apache.solr.handler.dataimport.JdbcDataSource.call(JdbcDataSource.ja
va:172)
atorg.apache.solr.handler.dataimport.JdbcDataSource.getConnection(JdbcDataSo
urce.java:528)
at org.apache.solr.handler.dataimport.JdbcDataSource$ResultSetIterator.
<init>(JdbcDataSource.java:317)
... 14 more
Caused by: java.io.EOFException: Can not read response from server. Expected
to
read 4 bytes, read 0 bytes before connection was unexpectedly lost.
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3011)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:567)
... 31 more
你的DIH没有问题。确保您的数据库连接字符串有效并且您的数据库已启动且 运行。
正如 Eric Wang 指出的那样,我使用了错误的端口号,之后我也收到了 SSL 证书错误,最终对我有用的 url 字符串是: url="jdbc:mysql://127.0.0.1:3306/indcat?useSSL=false&"