Book Image

Apache Solr Enterprise Search Server - Third Edition

By : David Smiley, Eric Pugh, Kranti Parisa, Matt Mitchell
Book Image

Apache Solr Enterprise Search Server - Third Edition

By: David Smiley, Eric Pugh, Kranti Parisa, Matt Mitchell

Overview of this book

<p>Solr Apache is a widely popular open source enterprise search server that delivers powerful search and faceted navigation features—features that are elusive with databases. Solr supports complex search criteria, faceting, result highlighting, query-completion, query spell-checking, relevancy tuning, geospatial searches, and much more.</p> <p>This book is a comprehensive resource for just about everything Solr has to offer, and it will take you from first exposure to development and deployment in no time. Even if you wish to use Solr 5, you should find the information to be just as applicable due to Solr's high regard for backward compatibility. The book includes some useful information specific to Solr 5.</p>
Table of Contents (19 chapters)
Apache Solr Enterprise Search Server Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Solritas – the integrated search UI


The contrib module, velocity, nicknamed Solritas, is a simple template engine that lets you build user interfaces directly in Solr using Apache Velocity, a very simple macro language to generate the HTML. It's similar to JSP or PHP, but with a simpler syntax consisting of just a handful of commands. It is very simple to pick up, as you can see in the following snippet of code, for rendering the HTML that displays the ID and name of an artist pulled from the first Solr document in a list of results:

#set($doc = $response.results.get(0))
#set($id = $doc.getFieldValue("id"))
<div>ID: $id</div>
<div>Name: #field('a_name')</div>

When a Velocity template is invoked, Solritas places some objects, indicated with a $ character, into a rendering context that you can use, such as $response and $request. In the preceding example, you can see that the first result in the response is assigned to the $doc object variable using the #set command...