delta-import for using multiple table in solr

耗尽温柔 提交于 2019-12-11 14:38:40

问题


I am new user to Solr. When I run full_import command for multiple tables it is working fine. The updated dates are written to dataimport.properties file. when i run delta import it is giving Exception occured while initilizing context..

The query deltaImportQueryanddeltaQueryindata-config.xml` is as follows:

<dataConfig>
<dataSource name="JdbcDataSource" 
    driver="com.mysql.jdbc.Driver" 
    url="jdbc:mysql://localhost:3306/hellodb" 
    user="root" 
    password="root" 
    batchSize="-1" />

<document>

<entity name="bhushan"         datasource="jdbcDataSource"  pk="id"         query="select * from bhushan" 
                               deltaImportQuery="select * from bhushan where id=='${dataimporter.delta.id}'"
                               deltaQuery="select id from bhushan where last_modified &gt; '${dataimporter.last_index_time}'"/>



<entity name="sunny"          datasource="jdbcDataSource"   pk="id"     
                              query="select weight as sunny from sunny where id='${bhushan.ID}'"
                              deltaQuery="select id from sunny where last_modified > '${dataimporter.last_index_time}'"
                              parentDeltaQuery="select id from bhushan where ID=${sunny.id}"/>
enter code here

</entity>

</entity>

</document>
</dataConfig>

Error on Solr console:

[Fatal Error] :30:3: The element type "document" must be terminated by the matching end-tag "</document>".
Mar 21, 2012 11:57:51 AM org.apache.solr.handler.dataimport.DataImportHandler inform
SEVERE: Exception while loading DataImporter
org.apache.solr.handler.dataimport.DataImportHandlerException: Exception occurred while initializing context
        at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:190)
        at org.apache.solr.handler.dataimport.DataImporter.<init>(DataImporter.java:101)
        at org.apache.solr.handler.dataimport.DataImportHandler.inform(DataImportHandler.java:113)
        at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:508)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:588)
        at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:137)
Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 3; The element type "document" must be
 terminated by the matching end-tag "</document>".
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at org.apache.solr.handler.dataimport.DataImporter.loadDataConfig(DataImporter.java:178)
        ... 30 more

Mar 21, 2012 11:57:51 AM org.apache.solr.servlet.SolrDispatchFilter init
SEVERE: Could not start SOLR. Check solr/home property
org.apache.solr.common.SolrException: FATAL: Could not create importer. DataImporter config invalid
        at org.apache.solr.handler.dataimport.DataImportHandler.inform(DataImportHandler.java:121)
        at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:508)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:588)
        at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:137)
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: Exception occurred while initializin
g context..

my databse is hellodb is as follows.. mysql> use hellodb; Database changed

mysql> select * from bhushan;
+----+---------+---------------------+
| id | name    | last_modified       |
+----+---------+---------------------+
|  1 | mangesh | 2012-03-17 14:20:57 |
|  2 | appa    | 2012-03-17 14:24:20 |
|  3 | xxxx    | 2012-03-17 14:27:09 |
|  4 | yyyy    | 2012-03-17 14:35:25 |
|  5 | zzzz    | 2012-03-17 14:37:59 |
|  6 | hhh     | 2012-03-19 11:45:27 |
+----+---------+---------------------+
6 rows in set (0.02 sec)

mysql> select * from sunny;
+------+--------+
| id   | weight |
+------+--------+
|    1 |    511 |
|    2 |    911 |
|    3 |   1111 |
|    4 |   5555 |
|    5 |   7777 |
|    6 |    888 |
+------+--------+
6 rows in set (0.01 sec)

Anybody know how to solve the problem?


回答1:


Your data-config file has an invalid XML syntax ...

The correct one:

<dataConfig>
<dataSource name="JdbcDataSource" 
    driver="com.mysql.jdbc.Driver" 
    url="jdbc:mysql://localhost:3306/hellodb" 
    user="root" 
    password="root" 
    batchSize="-1" />

<document>

<entity name="bhushan"         datasource="jdbcDataSource"  pk="id"         query="select * from bhushan" 
                               deltaImportQuery="select * from bhushan where id=='${dataimporter.delta.id}'"
                               deltaQuery="select id from bhushan where last_modified &gt; '${dataimporter.last_index_time}'">


</entity>
<entity name="sunny"          datasource="jdbcDataSource"   pk="id"     
                              query="select weight as sunny from sunny where id='${bhushan.ID}'"
                              deltaQuery="select id from sunny where last_modified > '${dataimporter.last_index_time}'"
                              parentDeltaQuery="select id from bhushan where ID=${sunny.id}">

</entity>


</document>
</dataConfig>


来源:https://stackoverflow.com/questions/9817414/delta-import-for-using-multiple-table-in-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!