简体   繁体   中英

dataimport not working from mysql to solr

verything is have configured properly. but when i run import from mysql to solr and try to index them, it says :-

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

here are my xml files :- db-data-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 Table

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 

Hi you are using a field job_title which is not a unique key neither required, so you should use the id required key and set it as unique key, or you should configure the unique key to be auto-incremented.

however to get things properly follow this: the id field is defined by default, check that it is in your schema.xml and that it is defined as unique key like below :

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

and also in your entity query you should index an 'id' which is unique of your db table like this:

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

this should resolve this problem :)

you got no required neither unique key. so you may create an autoincrement required id, or create one and add it as an entity field.

如果您已将id定义为架构中的唯一键,则需要在数据导入期间提供该值

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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