Book Image

Apache Solr 3.1 Cookbook

By : Rafał Kuć
Book Image

Apache Solr 3.1 Cookbook

By: Rafał Kuć

Overview of this book

<p>Apache Solr is a fast, scalable, modern, open source, and easy-to-use search engine. It allows you to develop a professional search engine for your ecommerce site, web application, or back office software. Setting up Solr is easy, but configuring it to get the most out of your site is the difficult bit.</p> <p>The Solr 3.1 Cookbook will make your everyday work easier by using real-life examples that show you how to deal with the most common problems that can arise while using the Apache Solr search engine. Why waste your time searching the Internet for solutions when you can have all the answers in one place?</p> <p>This cookbook will show you how to get the most out of your search engine. Each chapter covers a different aspect of working with Solr from analyzing your text data through querying, performance improvement, and developing your own modules. The practical recipes will help you to quickly solve common problems with data analysis, show you how to use faceting to collect data and to speed up the performance of Solr. You will learn about functionalities that most newbies are unaware of, such as sorting results by a function value, highlighting matched words, and computing statistics to make your work with Solr easy and stress free.</p>
Table of Contents (17 chapters)
Apache Solr 3.1 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Welcome to the Solr cookbook. You will be taken on a tour through the most common problems when dealing with Apache Solr. You will learn how to deal with the problems with Solr configuration and setup, how to handle common querying problems, how to fine-tune Solr instances, how to write Solr extensions, and many more things. Every recipe is based on real-life problems, and each recipe includes solutions along with detailed descriptions of the configuration and code that was used.

What this book covers

Chapter 1, Apache Solr Configuration: In this chapter, you will see how to handle Solr configuration, such as setting up Solr on different servlet containers, how to set up single and multicore deployments, and how to use Solr with Apache Nutch.

Chapter 2, Indexing your Data: In this chapter, you will learn how to send your data in different formats, how to handle binary file format, and what can be done when using the Data Import Handler.

Chapter 3, Analyzing your Text Data: This chapter will tell you how to overcome common problems you may encounter while analyzing your text data.

Chapter 4, Solr Administration: This chapter will guide you through the Solr administration panel, index replication setup, and its maintenance.

Chapter 5, Querying Solr: This chapter will help you with common problems when sending queries to Solr, such as searching for a word, phrase, boosting, sorting, and so on.

Chapter 6, Using Faceting Mechanism: This chapter will show you the beautiful world of the Apache Solr faceting mechanism, including tasks like getting the number of documents with the same field value, matching the same query, matching given range values, and so on.

Chapter 7, Improving Solr Performance: This chapter will help you troubleshoot performance problems with your Apache Solr instance. Here you will find tips about setting up your Solr instance caches, improving faceting performance, setting up a sharded deployment, or getting the first top documents out of millions fast.

Chapter 8, Creating Applications that Use Solr and Developing your Own Solr Modules: In this chapter, you will learn how to use Solr with different programming languages and how to develop your own modules for Apache Solr server.

Chapter 9, Using Additional Solr Functionalities: In this chapter, you will find recipes that will show you how to use additional Solr components, like the highlighting mechanism, spellchecker, statistics, or grouping mechanism.

Chapter 10, Dealing with Problems: This chapter concentrates on helping you with common problems when running the Apache Solr search server. In this part of the book, you will find recipes that will help you in dealing with a corrupted index, with out-of-memory errors, garbage collection, and so on.

What you need for this book

In order to be able to run most of the examples in this book, you will need an Oracle Java Runtime Environment version 1.5 or newer, and of course the 3.1 version of Solr search server.

A few chapters require additional software, such as Apache Nutch 1.2 or your favorite IDE and a Java compiler to be able to edit and compile examples provided in the book.

Who this book is for

Developers who are working with Apache Solr and would like to know how to combat common problems will find this book of great use. Knowledge of Apache Lucene would be a bonus, but is not required.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "It's based on the solr.PointType class and is defined by two attributes."

A block of code is set as follows:

<add>
 <doc>
  <field name="id">1</field>
  <field name="name">Solr cookbook</field>
  <field name="description">This is a book that I'll show</field>
 </doc>
</add>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<fieldType name="text_stem" class="solr.TextField">
 <analyzer>
  <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  <filter class="solr.SnowballPorterFilterFactory" />
 </analyzer>
</fieldType>

Any command-line input or output is written as follows:

java -jar post.jar ch3_html.xml

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "If you want to analyze the field type, just type in the appropriate name type and change the name selection to field."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.