2014-03-01 37 views
0

配置正确。但是当我运行从MySQL进口SOLR并尝试为他们,它说: -dataimport不能从mysql工作到solr

Indexing completed. Added/Updated: 0 documents. Deleted 0 documents. 
Requests: 1, Fetched: 25, Skipped: 0, Processed: 0 
Started: about a minute ago 

这里是我的xml文件: - DB数据-config.xml中

<?xml version="1.0" encoding="UTF-8" ?> 
<dataConfig> 
    <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/delance" user="root" password="pass" batchSize="1"/> 
    <document name="Jobs"> 
    <entity name="Jobs" query="select * from Jobs"> 
     <field name="job_title" column="job_title" /> 
    </entity> 
    </document> 
</dataConfig> 

schema.xml中

<field name="job_title" type="string" indexed="true" stored="true"/> 

职位表

Jobs CREATE TABLE `Jobs` (                   
      `job_id` int(11) NOT NULL AUTO_INCREMENT,             
      `description` longtext,                  
      `job_date` varchar(100) DEFAULT NULL,              
      `job_hash` varchar(32) NOT NULL,                
      `job_title` varchar(500),                   
      `time_limit` varchar(50) DEFAULT NULL,              
      `users_user_id` int(11) DEFAULT NULL,              
      PRIMARY KEY (`job_id`),                  
      KEY `FK2350763B6AF29A` (`users_user_id`),             
      CONSTRAINT `FK2350763B6AF29A` FOREIGN KEY (`users_user_id`) REFERENCES `Users` (`user_id`) 
     ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=latin1 
+0

什么是schema.xml中的uniqueKey? – Persimmonium

+0

我没有定义uniqueKey,是否有必要。 schema.xml包含默认的 ID。 – user3321738

+0

你的模式中是否也有id字段? – Persimmonium

回答

0

如果定义ID在你的架构中的唯一密钥,则需要提供该值在数据导入

<field name="id" column="job_id" /> 
2

嗨,你使用的是场JOB_TITLE这不是不需要唯一的密钥,因此您应该使用id所需的密钥并将其设置为唯一密钥,或者应该将唯一密钥配置为自动递增。

然而得到的东西正确遵循这样的: id字段是默认定义,请检查它是否在你的schema.xml中,它被定义为唯一键象下面这样:

<fields> <field name="id" type="string" indexed="true" stored="true" required="true"/> <field name="job_title" type="string" indexed="true" stored="true"/> <!-- other fields definition ... --> </fields> <uniqueKey>id</uniqueKey>

而且在实体查询,你应该指数的“身份证”,这是唯一的db表是这样的:

<document name="Jobs"> <entity name="Jobs" query="select * from Jobs"> <!-- id here should be stirng, or you can change its type in its definition in the schema.xml --> <field name="id" column="table_id" /> <field name="job_title" column="job_title" /> </entity> </document>

这应该解决这个问题: )

1

你不需要任何独特的密钥。 所以你可以创建一个自动增量所需的id,或者创建一个并将其作为实体字段添加。