5

I am using Spring Data (Mongo) for my web application (close to a social networking website). Now, I wish to provide search capabilities over the content written within the application (such as posts, tags, friends, etc.).

I believe Lucene/Solr is one of the better libraries to go for such cases, but am not sure how to use (integrate?) it with Spring Data (or maybe there is some inherent support within Spring for it).

Would appreciate help (documentation, links, blog posts, etc.) on this!

1
  • 1
    i dont really know spring data, but you should read up solr documentation - i guess that could help!
    – aishwarya
    Dec 4, 2011 at 16:25

4 Answers 4

5

Though the post has been around for a while, you may have a look at this one https://github.com/SpringSource/spring-data-solr/

3

The Spring Data for Solr project provides a natural Spring Data like API for querying data from Solr. Read the examples for a quick overview.

2

I found a good read here - http://adeithzya.wordpress.com/2011/08/25/using-apache-solr-with-spring-framework - that hits the nail on its head!

1

Integrating them is relatively easy, the difficult part is maintaining data consistency between them. For example, how would you answer these questions:

  • How and when do you intend to perform CRUD with mongo and sorl? Do you write to Mongo first (with/without waiting for a confirmation?) and then to Solr?
  • if you're using async writes with mongo, what happens when you send the data to solr, and then get an exception for mongo (data exist in solr, but doesn't exist in mongo)?
  • What happens if you get an error while trying to write to solr (data exist in mongo but not in solr)?
  • if you delete something from mongo, and right after that someone performs a search where solr returns that very deleted document because solr stil has that document indexed?

The point is there'll be an inconsistency window where mongo and solr are not in sync, and you probably want to handle at least some of the issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.