Solr delta导入查询异常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Solr delta导入查询异常相关的知识,希望对你有一定的参考价值。

这是我的数据库配置文件,我可以正确导入,但问题是delta导入

有两个例外

  1. mysql相关的数据源异常
  2. DHI
<dataConfig>
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://10.30.2.32:3306/artemis" batchSize="-1"

user =“username”password =“password”/>

<document>
<entity name="job" pk="job_id"

 query="SELECT * FROM job"
 deltaImportQuery="SELECT * FROM job WHERE job_id = '${dataimporter.delta.id}'"
 deltaQuery="SELECT job_id FROM job WHERE updated_date > convert_tz('${dataimporter.last_index_time}','+00:00','-05:30')">

<field column="job_id" name="jobId"/>
<field column="keywords" name="keywords"/>
<field column="speaciality" name="speaciality"/>
<field column="salary_min" name="salaryMin"/>
<field column="salary_max" name="salaryMax"/>
<field column="created_date" name="createdDate"/>
<field column="updated_date" name="updatedDate"/>
<field column="updated_date" name="updatedDate"/>  
<field column="experience_from" name="experienceFrom"/>
<field column="experience_to" name="experienceTo"/>
<field column="job_title" name="jobTitle"/> 

<entity name="city" 

 query="SELECT * FROM city where city_id ='${job.place_of_interview_id}'"
 deltaQuery="select city_id from city where updated_date >convert_tz('${dataimporter.last_index_time}','+00:00','-05:30')"
 parentDeltaQuery="select job_id from job where place_of_interview_id='${city.city_id}'" 
 >



<field column="name" name="city"/>

<entity name="district" 
 query="SELECT * FROM district where district_id='${city.district_id}'"
 deltaQuery="select district_id from district where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select city_id from city where district_id='${district.district_id}'"
 >  
  <field column="name" name="district"/>

 <entity name="state" 
 query="SELECT * FROM state where state_id='${district.state_id}'"
 deltaQuery="select state_id from state where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select district_id from district where state_id='${state.state_id}'"
 >  
  <field column="name" name="state"/>

 <entity name="country" 
 query="SELECT * FROM country where country_id='${state.country_id}'"
 deltaQuery="select country_id from country where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select state_id from state where country_id='${country.country_id}'"
 >  
  <field column="name" name="country"/>

 <entity name="region" 
 query="SELECT * FROM region where region_id='${country.region_id}'"
 deltaQuery="select region_id from region where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select country_id from country where region_id='${region.region_id}'"
 >  
  <field column="name" name="region"/>

</entity>   


</entity> 


</entity> 


</entity>

</entity>

 <entity name="jobFunction" 
 query="SELECT * FROM job_function where job_function_id='${job.job_function_id}'"
 deltaQuery="select job_function_id from job_function where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select job_id from job where job_function_id='${jobFunction.job_function_id}'"
 >  
  <field column="name" name="jobFunction"/>

 <entity name="jobCategory" 
 query="SELECT * FROM master_data where id='${jobFunction.job_category_id}'"
 deltaQuery="select id from master_data where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select job_function_id from job_function where job_category_id='${jobCategory.id}'"
 >  

 <field column="name" name="jobCategory"/>

</entity>  

</entity>  



 <entity name="companyName" 
 query="SELECT * FROM employer where employer_id='${job.employer_id}'"
 deltaQuery="select employer_id from employer where updated_date > '${dataimporter.last_index_time}'"
 parentDeltaQuery="select job_id from job where employer_id='${companyName.employer_id}'"
 >  

 <field column="company_name" name="companyName"/>

</entity>  


</entity>

</document>

</dataConfig>

我在delta导入时遇到异常

/29/2017, 6:25:47 PM
ERROR true
JdbcDataSource
Ignoring Error when closing connection
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@15196a0f is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:880)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:876)
    at com.mysql.jdbc.MysqlIO.checkForOutstandingStreamingData(MysqlIO.java:3111)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2366)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2594)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2541)
    at com.mysql.jdbc.ConnectionImpl.rollbackNoChecks(ConnectionImpl.java:4738)
    at com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:4630)
    at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4271)
    at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1515)
    at org.apache.solr.handler.dataimport.JdbcDataSource.closeConnection(JdbcDataSource.java:507)
    at org.apache.solr.handler.dataimport.JdbcDataSource.close(JdbcDataSource.java:492)
    at org.apache.solr.handler.dataimport.DocBuilder.closeEntityProcessorWrappers(DocBuilder.java:288)
    at org.apache.solr.handler.dataimport.DocBuilder.closeEntityProcessorWrappers(DocBuilder.java:290)
    at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:277)
    at org.apache.solr.handler.dataimport.DataImporter.doDeltaImport(DataImporter.java:444)
    at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:482)
    at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:461)
3/29/2017, 6

java.lang.RuntimeException: java.lang.IllegalArgumentException: deltaQuery has no column to resolve to declared primary key pk='jobId'
    at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:270)
    at org.apache.solr.handler.dataimport.DataImporter.doDeltaImport(DataImporter.java:444)
    at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:482)
    at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:461)
Caused by: java.lang.IllegalArgumentException: deltaQuery has no column to resolve to declared primary key pk='jobId'
    at org.apache.solr.handler.dataimport.DocBuilder.findMatchingPkColumn(DocBuilder.java:755)
    at org.apache.solr.handler.dataimport.DocBuilder.collectDelta(DocBuilder.java:808)
    at org.apache.solr.handler.dataimport.DocBuilder.collectDelta(DocBuilder.java:789)
    at org.apache.solr.handler.dataimport.DocBuilder.doDelta(DocBuilder.java:344)
    at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:224)
    ... 3 more
答案

你可以将<'$ {dataimporter.delta.id}'>替换为$ {dataimporter.delta.job_id}并进行测试。

deltaImportQuery :(仅用于delta-import)。有一个名称空间$ {dih.delta.column-name},可以在此查询中使用。例如:select * from tbl,其中id = $ {dih.delta.id} Solr1.4

如上所述,我们只能在delta命名空间中使用列名。

参考: https://wiki.apache.org/solr/DataImportHandler https://wiki.apache.org/solr/DataImportHandler#Configuration_in_data-config.xml

以上是关于Solr delta导入查询异常的主要内容,如果未能解决你的问题,请参考以下文章

xml 特殊字符 导致的 solr 数据导入异常

solr 学习片段

solr 数据导入处理程序 jndi websphere

Solr Highlighting:如何为同一字段请求多个片段长度?

Solr配置maxBooleanClauses属性不生效原因分析

solr-geohsah 按照距离搜索分组