Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate apache solr in spring MVC using maven on tomcat

I am developing a web application using spring MVC and I have hosted this using tomcat. I have a requirement where I want to integrate apache-solr to my search engine.

I tried looking on internet for various tutorials but couldn't find a proper one to explain the steps.

So my requirements are

  1. How to integrate apache solr in spring MVC using maven dependency(I am using tomcat to host the server)
  2. Basic tutorials to add data files with solr
  3. How can I integrate it to pick up the data from my database. I am using hibernate to map my database tables.

After going through some tutorials I think spring-data-solr is suitable for spring MVC.

P.S. I am new to all the above technologies.

like image 640
Anil Avatar asked Nov 01 '22 13:11

Anil


1 Answers

For Solr in general, you should refer to the Solr reference guide for help. It is meant for the upcoming Solr 5.0 release, but most of the guide is still relevant for 4.0 and the other documentation (the old wiki) is of poor quality.

Solr requires a separate installation; it is not just a maven dependency. To install Solr, follow the install instructions from the guide.

To contact solr in your java layer, you can use solr-j, which you can add as a maven dependency, as noted here, the latest version is 4.10.2:

<dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> <version>4.10.2</version> </dependency>

There's lots of documentation about how to use Solr-J here. spring-data-solr may also work for you.

Hibernate has nothing to do with the integration of solr and spring. Solr can load from your DB directly using the data import handler or you can update documents in solr via its REST API.

like image 96
beerbajay Avatar answered Nov 15 '22 09:11

beerbajay