delta-import在solr中使用多个表

时间:2012-03-22 06:24:06

标签: solr dataimporthandler

我是Solr的新用户。当我为多个表运行full_import命令时,它工作正常。更新的日期将写入dataimport.properties文件。当我运行delta导入时,它会在启动上下文时发生异常。

查询deltaImportQuery and deltaQuery in data-config.xml`如下:

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

Solr控制台上出错:

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

我的数据库是hellodb如下.. MySQL的&GT;用hellodb; 数据库已更改

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)

有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

您的数据配置文件的XML语法无效......

正确的一个:

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