Wasim A.
Wasim A.

Reputation: 9866

Solr index multiple tables from MySQL

I have following mysql tables

 1. user(user_id,email) 
 2. tweets(tweet_id,user_id,tweet) 
 3. tags(tag_id,tag)
 4. tweets_tags(tweet_id,tag_id)

I want to show current user's tweets under "My Tweets" Tab in application. I want to get following data from Solr

user_id
email
tweet where user_id=x
tags where tweet_id=xx

How to index those mysql table on Solr? I only what to know the code of schema.xml and data-config.xml for Full/Delta import.

Note : I am not asking about MySQL connector etc, I have done already.

Upvotes: 0

Views: 3009

Answers (2)

radoo
radoo

Reputation: 168

The use case you've described doesn't seem to justify using solr. You would just make sure you have proper keys and indexes and do it in mysql directly.

If for some reason you MUST use solr, you could probably prepare all the data and feed it to solr in a tag/tweet/user structure like this

  • user1 - tweet1 - tag1
  • user1 - tweet1 - tag2
  • user1 - tweet2 - tag1

and so on.

Then from solr you query by user, and then sort and group by tweet and then tag. However I must state again that the solution I just described is implemented much safer with a higher confidence on the result by using plain sql.

Should you provide more details on your desired outcome, I'd be happy to suggest the database structure along with the necessary foreign keys and indexes and the queries you need to get your data out.

Upvotes: 1

vuky
vuky

Reputation: 603

If you are using DIH (dataimporterhandler), I guess that link should be the solution for you: Import with sub entities If you have problem with writing the exact configurations, please let me know, I can assist you.

Upvotes: 0

Related Questions