Book Image

Solr Cookbook - Third Edition

By : Rafal Kuc
Book Image

Solr Cookbook - Third Edition

By: Rafal Kuc

Overview of this book

Table of Contents (18 chapters)
Solr Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Welcome to Solr Cookbook, Third Edition. You will be taken on a tour of the most common problems that a user might face while dealing with Apache Solr. You will also explore some of the features that were recently introduced in Solr. You will learn how to deal with the problems when configuring and setting up Solr, handle common queries, fine-tune Solr instances, set up and use SolrCloud, use faceting and grouping, fighting common problems, and many more things. Each and every recipe is based on real-life problems and provides solutions along with detailed descriptions of the configuration and code that was used.

What this book covers

Chapter 1, Apache Solr Configuration, covers Solr configuration recipes, along with setting up ZooKeeper, migrating from master to slave, and configuring Solr for different use cases.

Chapter 2, Indexing Your Data, as the name suggests, explains data indexing, such as binary files indexing, using Data Import Handler, language detection, updating a single field of document, and much more.

Chapter 3, Analyzing Your Text Data, concentrates on common problems when analyzing your data, such as stemming, geographical location indexing, or using synonyms.

Chapter 4, Querying Solr, describes querying Apache Solr, such as nesting queries, affecting the scoring of documents, phrase searching, or using the parent-child relationship.

Chapter 5, Faceting, is dedicated to the faceting mechanism in which you can find the information needed to overcome some problems that you might encounter while working with Solr and faceting.

Chapter 6, Improving Solr Performance, focuses on improving your Apache Solr cluster performance with information such as cache configuration, indexing speed up, and much more.

Chapter 7, In the Cloud, covers the cloud side of Solr—SolrCloud, setting up collections, replicas configuration, distributed indexing and searching, as well as aliasing and shard manipulation.

Chapter 8, Using Additional Functionalities, explains how we can highlight long text fields, sort results on the basis of function value, check user spelling mistakes, and use the grouping functionality.

Chapter 9, Dealing with Problems, is a small chapter dedicated to the most common situations such as memory problems, tuning segment merges, and others.

Chapter 10, Real-life Situations, describes how to handle real-life situations such as implementing different autocomplete functionalities, using near real-time search, or improving query relevance.

What you need for this book

In order to run most of the examples in this book, you will need Java Runtime Environment 1.7 or the newer version and of course, the 4.10 or the newer version of Apache Solr search server. To run examples found in this book, you might need a web browser or a command-line tool that is able to run HTTP requests such as curl.

The recipes in this book (unless stated otherwise) are tested in a Linux environment with the latest available Version of Solr 5.0. For Windows-based hosts, the single quotes should be replaced with double quotes in the commands. Remember that during the writing of this book, the final Version of Solr 5.0 was not released and there might have been changes between the version used during testing and the released Version of Solr 5.0.

A few chapters in this book require additional software such as Apache ZooKeeper 3.4.3 or Jetty.

Who this book is for

This book is for intermediate Solr Developers who are willing to learn and implement pro-level practices, techniques, and solutions. This edition will specifically appeal to developers who wish to quickly get to grips with the changes and new features of Apache Solr 5.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

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

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The lib entry in the solrconfig.xml file tells Solr to look for all the JAR files from the ../../langid directory."

A block of code is set as follows:

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="description" type="text_general" indexed="true" stored="true" />
<field name="langId" type="string" indexed="true" stored="true" />

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

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="description" type="text_general" indexed="true" stored="true" />
<field name="langId" type="string" indexed="true" stored="true" />

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

curl 'localhost:8983/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"1","file":{"set":"New file name"}}]'

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The Overview page for a collection gives you basic statistics about the core of the collection such as number of documents, heap memory usage, version of the index, number of segments, and so on."

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 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/submit-errata, 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.