Using Lucene / Solr with Spring Data

I am using Spring Data (Mongo) for my web application (next to the social networking site). Now I want to provide a search on the content written in the application (for example, messages, tags, friends, etc.).

I believe Lucene / Solr is one of the best libraries for such cases, but I'm not sure how to use (integrate?) It with Spring Data (or maybe there is some internal support inside Spring for This).

Would thank for the help (documentation, links, blog posts, etc.) on this!

+4
source share
4 answers

I found a good text here - http://adeithzya.wordpress.com/2011/08/25/using-apache-solr-with-spring-framework - which hits a nail on my head!

+1
source

Although the post has been around for a while, you can take a look at this https://github.com/SpringSource/spring-data-solr/

+5
source

The Spring Data for Solr project provides a natural Spring Data API for querying data from Solr. For a quick overview, read the examples .

+3
source

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

  • How and when are you going to do CRUD with Mongo and Sorrel? Do you write first in Mongo (waiting for confirmation or not), and then Solr?
  • If you use async records with mongo, what happens when you send data to solr and then get an exception for mongo (data exists in solr but not in mongo)?
  • What happens if you get an error while trying to write to solr (data exists in mongo but not in solr)?
  • if you delete something from mongo, and right after that, someone searches in which solr returns this very deleted document, because solr stil has this document indexed?

The bottom line is that there will be a window of inconsistency in which mongo and solr are not synchronized, and you probably want to handle at least some of the problems.

0
source

Source: https://habr.com/ru/post/1384581/


All Articles