Is usage of EmbeddedSolrServer now outdated & not

2020-04-11 11:14发布

问题:

I need to add search functionality to my Java webapp running on tomcat, along with the database as well on the same machine.

Since I'm planning to use Solr on this same machine but which implementation should be used? I thought Embedded one is more preferable since I need to be adding data from the same machine, so adding via HTTP wont make much sense, no? & moreover running Solr as a separate web app would consume more resources than the embedded one(isn't it?).

But now that the use of EmbeddedSolrServer is not recommended, how do people use Solr when they need to keep Solr on the same machine as the webapp ?

回答1:

You can setup Solr as another "web service" in the same Tomcat your are using for your web app, do the proper configuration and use it via the HTTP/REST interface. Alternatively you can also use the out-of-the-box Jetty container. Check for more details on how to install here: http://wiki.apache.org/solr/SolrInstall.

I do not believe using embedded solr will be consuming (much) less resources... if you really do not want to separate things (application and solr), probably you should be looking on Lucene directly and not Solr, since the main goal of Solr is to allow the creation of web service interface for Lucene, which can be accessed from any application (it has several other extensions - http://lucene.apache.org/solr/features.html, but the core of Solr is the Lucene java search library).



回答2:

The page you reference answers your question. You run Solr on the same machine in its own JVM, as a service, and interact with it over HTTP (to localhost).