Solr delta导入查询异常

时间:2017-03-29 13:21:25

标签: solr

这是我的db配置文件,我能够正确导入 但是问题到了 delta import

有两个例外

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

    用户=&#34;用户名&#34;密码=&#34;密码&#34; /&GT;

    <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
    

1 个答案:

答案 0 :(得分:1)

可以替换&lt;'$ {dataimporter.delta.id}'&gt;到$ {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