简体   繁体   English

delta-import在solr中使用多个表

[英]delta-import for using multiple table in solr

I am new user to Solr. 我是Solr的新用户。 When I run full_import command for multiple tables it is working fine. 当我为多个表运行full_import命令时,它工作正常。 The updated dates are written to dataimport.properties file. 更新的日期将写入dataimport.properties文件。 when i run delta import it is giving Exception occured while initilizing context.. 当我运行delta导入时,它会在启动上下文时发生异常。

The query deltaImportQuery and deltaQuery in data-config.xml` is as follows: 查询deltaImportQuery and deltaQuery in数据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>

Error on Solr console: 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..

my databse is hellodb is as follows.. mysql> use hellodb; 我的数据库是hellodb如下.. mysql>使用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? 有谁知道如何解决这个问题?

Your data-config file has an invalid XML syntax ... 您的data-config文件具有无效的XML语法...

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM