The concept of "Embedded Solr" came about in 2007 when some Java developers wanted to get the goodies Solr added on top of the Lucene Java API, but without running a separate Java process.

This wiki page originally served as an example of how, by directly compiling against the classes provided in the Solr WAR, you could add code directly to an existing Java application to do the necessary setup to initialize a SolrCore, add documents to the index, and execute queries.

Those examples are still available in the historic versions of this page, but they are no longer recommended (not that they ever really were).

The simplest, safest, way to use Solr is via Solr's standard HTTP interfaces. Embedding Solr is less flexible, harder to support, not as well tested, and should be reserved for special circumstances.

That said, the Solrj Java API provides an EmbeddedSolrServer implementation. This is the recommended way to "embed" Solr into a Java application. It provides the exact same API as you would use if you were connecting to a remote Solr instance -- which makes it easy to convert later if you'd like; and by using it you can be sure you will be Using API calls that will be supported in the future.

EmbeddedSolr (last edited 2009-09-20 22:05:20 by localhost)