Using Solarium with SOLR for Search – Setup

Posted by Unknown on Thursday, May 1, 2014

Apache’s SOLR is an enterprise-level search platform based on Apache Lucene. It provides a powerful full-text search along with advanced features such as faceted search, result highlighting and geospatial search. It’s extremely scalable and fault tolerant.


Well known websites said to use SOLR to power their search functions include digg, Netflix, Instagram and Whitehouse.gov (source).


While SOLR is written in Java, it’s accessible via HTTP, making it possible to integrate with whatever programming language you prefer. If you’re using PHP then the Solarium Project makes integration even easier, providing a level of abstraction over the underlying requests which enables you to use SOLR as if it were a native implementation running within your application.


In this series, I’m going to introduce both SOLR and Solarium side-by-side. We’ll begin by installing and configuring SOLR and creating a search index. Then, we’ll look at how to index documents. Next, we’ll implement a basic search and then expand it with some more advanced features such as faceted search, result highlighting and suggestions.


As we go along, we’re going to build a simple application for searching a collection of movies. You can grab the source code here, or see an online demo here.



Basic Concepts and Operation


Before we delve into the implementation, it’s worth looking at a few basic concepts and an overall view of what will happen.


SOLR is a Java application which runs as a web service, typically in a servlet container such as Tomcat, Glassfish or JBoss. You can manipulate and query it over HTTP using XML, JSON, CSV or binary format - so you can use any programming language for your application. However, the Solarium library provides a level of abstraction, allowing you to call methods as if SOLR were a native implementation. For the purposes of this tutorial we’ll be running the SOLR on the same machine as our application, but in practice it could be located on a separate server.


SOLR creates a search index of documents. Often that mirrors what we might consider a document in real-life; an article, blog post or even a full book. However a document can also represent any object applicable to your application - a product, a place, an event - or in our example application, a movie.


At its most basic, SOLR allows you to perform full text searches on documents. Think search engines; you’ll typically search for a keyword, a phrase or a full title. You can only get so far with SQL’s LIKE clause; that’s where fulltext search comes in.


You can also attach additional information to an indexed search document that doesn’t necessarily get picked up by a text-based search; for example, you can incorporate the price of a product, the number of rooms in a property or the date an item was added to the database.


Facets are one of the most useful features of SOLR. You’ll probably have seen faceted search if you’ve ever shopped online; facets allow you to “drill down” search results by applying “filters”. For example, having searched an online bookstore you might use filters to limit the results to those books by a particular author, in a particular genre or in a particular format.


An instance of SOLR runs with one or more cores. A core is a collection of configuration and indexes, each with its own schema. Typically, a single instance is specific to a particular application. Since different types of content can have very different structures and information - for example, consider the difference between a product, an article and a user - an application often has multiple cores within an SOLR instance.



Installing SOLR


I’m going to provide instructions for how to setup SOLR on a Mac; for other operating systems, consult the documentation - or alternatively, you can download Blaze, an appliance with SOLR pre-installed.


Continue reading %Using Solarium with SOLR for Search – Setup%




more

{ 0 comments... » Using Solarium with SOLR for Search – Setup read them below or add one }

Post a Comment

Popular Posts