Reputation: 241
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
Upvotes: 0
Views: 297
Reputation: 21
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.
Upvotes: 1
Reputation: 1780
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 :)
Upvotes: 2
Reputation: 951
If you have defined id as the unique key in your schema , then you need to provide that value during the data import
<field name="id" column="job_id" />
Upvotes: 0