Question

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!

Was it helpful?

Solution 3

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!

OTHER TIPS

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top