171

I know that Lucene and Solr are 2 differents Apache projects that are made to work together, but I don't understand what is the aim of each project.

For what I understood until now is that Lucene is used to create a search index and Solr use this index to perform searches. Am I right or is this a totally different approach?

guettli
  • 26,461
  • 53
  • 224
  • 476
darkheir
  • 8,317
  • 6
  • 43
  • 64
  • 5
    Doesn't http://lucene.apache.org/solr/ (and the equivalent page for Lucene) answer that? – NPE Mar 29 '13 at 13:52
  • Yeah you're right, the solr features page clarify the difference. Si If I understand I could use Lucene alone, but Solr need Lucene to work. – darkheir Mar 29 '13 at 13:59
  • 2
    Unlike Lucene, Solr is a web application (WAR) which can be deployed in any servlet container, e.g. Jetty, Tomcat, Resin, etc. Solr can be installed and used by non-programmers. Lucene cannot. More on http://www.lucenetutorial.com/lucene-vs-solr.html – Lucky Dec 28 '15 at 12:23

7 Answers7

235

@darkheir: Lucene and Solr are 2 differents Apache projects that are made to work together, I don't understand what is the aim of each project.

1) Solr uses Lucene under the hood. Lucene has no clue about the Solr API.

2) Lucene is a powerful search engine framework that lets us add search capability to our application. It exposes an easy-to-use API while hiding all the search-related complex operations. Any application can use this library, not just Solr.

3) Solr is built around Lucene. It is not just an http-wrapper around Lucene but has been known to add more arsenal to Lucene. Solr is ready-to-use out of box. It is a web application that offers related infrastructure and a lot more features in addition to what Lucene offers.

@darkheir: Lucene is used to create a search index and Solr use this index to perform searches. Am I right or is this a totally different approach?

4) Lucene doesn't just create the Index for the consumption by Solr. Lucene handles all the search related operations. Any application can use the Lucene framework.

Examples are Solr, Elastic Search, LinkedIn (yes, under the hood), etc..

Check out this article: Lucene vs Solr

UPDATE (6/18/14)

When to use Lucene?

  • You are a search engineer AND
  • You are a programmer AND
  • You want full control over almost all the internals of Lucene AND
  • Your requirements demand you to do all sorts of geeky customization to Lucene AND
  • You are willing to take care of infrastructure elements of your search like scaling, distribution, etc.

When to use Solr?

  • At least one of the above didn't make sense. OR
  • You want something that is ready to use out-of-the-box (even without knowledge of Java) OR
  • Your infrastructure requirements outweigh search customization requirements.

NOTE: I don't mean that Solr is hard to customize. Solr is very flexible and provides a lot of pluggable API points, allowing you to throw-in your code.

There are people, falling under 'have to use Lucene' camp, but still prefer Solr to plain Lucene as it's easy to use. However, they never restrain themselves from customizing Solr to the maximum extent.

BTW, I see that there are more resources on Solr (4.x) than Lucene (4.x).

Rob Bednark
  • 19,968
  • 18
  • 67
  • 100
phanin
  • 4,987
  • 4
  • 26
  • 43
32

Lucene is a low level Java library (with ports to .NET, etc.) which implements indexing, analyzing, searching, etc.

Solr is a standalone pre-configured product/webapp which uses Lucene. If you prefer dealing with HTTP API instead of Java API, Solr is for you. Solr has also got some extra features on top (e.g. grouping).

mindas
  • 25,644
  • 13
  • 93
  • 149
23

A simple way to conceptualize the relationship between Solr and Lucene is that of a car and its engine. You can't drive an engine, but you can drive a car. Similarly, Lucene is a programmatic library which you can't use as-is, whereas Solr is a complete application which you can use out-of-box.

Source: Lucene-vs-solr - Lucene Tutorial

Lucky
  • 14,677
  • 16
  • 104
  • 145
Vikas Kumar
  • 1,591
  • 13
  • 15
  • 7
    Which is copy-pasted from http://www.lucenetutorial.com/lucene-vs-solr.html Please mention the source whenever you copy paste answer quoting the source. ;) – Lucky Dec 28 '15 at 12:12
  • 1
    Page seems to be offline now. – dev_feed Jun 09 '16 at 12:10
16

Solr is built on top of lucene to provide a search platform.

Search platform in the following layers from bottom to top:

  • Data
    • Purpose: Represent various data types and sources
  • Document building
    • Purpose: Build document information for indexing
  • Indexing and searching
    • Purpose: Build and query a document index
  • Logic enhancement
    • Purpose: Additional logic for processing search queries and results
  • Search platform service
    • Purpose: Add additional functionalities of search engine core to provide a service platform.
  • UI application
    • Purpose: End-user search interface or applications

solr stack

Reference article : Enterprise search

Community
  • 1
  • 1
mingxue
  • 571
  • 5
  • 10
13

SOLR is a wrapper over Lucene index.

It is simple to understand: SOLR is car and Lucene is its engine. You just need to know how to drive car (SOLR) and also need to know few things of engine (Lucene) in case if there will be any issue in your car engine.

Have a safe drive :)

Behzad Qureshi
  • 478
  • 1
  • 7
  • 15
  • 3
    Not to mention that if you were so inclined, you *could* build your own car using the Lucene engine. – hintss May 08 '17 at 14:53
1

You can imagine it the following way - Apache Lucene is the library that is used internally by the Apache Solr. It is written in Java and provides amazing full-text search and indexing capabilities. It can analyze a large number of languages from all over the world and prepare the text in such languages to efficient and fast search and analysis. Lucene is a library - you could use it directly in your application and implement everything yourself, but the Apache Solr provides a lot out of the box.

Apache Solr search engine provides things like HTTP APIs that you can use to send data to them and later search on that data. You can control the search engines using the API, create distributed environments and automatically distribute the data across multiple nodes and many, many more.

Rafal
  • 116
  • 4
0

You can find a good comparison about the purpose of lucence and solar here:

http://www.lucenetutorial.com/lucene-vs-solr.html

TLDR: Lucence is just the engine, Solar is the car you can drive (equipped with rest-api etc.)

Martin Abraham
  • 734
  • 7
  • 23