Reader small image

You're reading from  Apache Solr PHP Integration

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781782164920
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Jayant Kumar
Jayant Kumar
author image
Jayant Kumar

Jayant Kumar is an experienced software professional with a bachelor of engineering degree in computer science and more than 14 years of experience in architecting and developing large-scale web applications. Jayant is an expert on search technologies and PHP and has been working with Lucene and Solr for more than 11 years now. He is the key person responsible for introducing Lucene as a search engine on www.naukri.com, the most successful job portal in India. Jayant is also the author of the book Apache Solr PHP Integration, Packt Publishing, which has been very successful. Jayant has played many different important roles throughout his career, including software developer, team leader, project manager, and architect, but his primary focus has been on building scalable solutions on the Web. Currently, he is associated with the digital division of HT Media as the chief architect responsible for the job site www.shine.com. Jayant is an avid blogger and his blog can be visited at http://jayant7k.blogspot.in. His LinkedIn profile is available at http://www.linkedin.com/in/jayantkumar.
Read more about Jayant Kumar

Right arrow

Preface

Searches are an integral part of any web application that is built today. Whether it is a content site, a job site, an e-commerce site, or any other website, searches play a very important role in helping the user locate the information that he/she is looking for. As a developer, it is imperative to provide the user of the website with all the possible tools for searching and narrowing down to the required information. Apache Solr is a full text search engine, which provides a large list of features for searches. PHP is the preferred programming language for building websites. This book guides the reader on the integration between PHP and Solr.

When a user performs a search on the website, he wants the results to be relevant based on certain criteria. Let us take the example of an e-commerce website. A search can happen on product names, brand names, model numbers, and product types. Once the results are visible, it is important to provide a set of facets on price, size, and some other features of the products in the search result, which can be used to narrow down the results to exactly what is desired. Autocompleting the search query as the user types and providing spelling suggestions are some of the advanced search functionalities that are visible on some websites.

The idea of this book is to bring attention to these and many other search functionalities that Solr provides to the community of PHP developers and to guide PHP developers who build these websites on exploring and using these search functionalities to build features related to searches into their websites. This book not only provides a quick step-by-step PHP code for fast development of search features but also goes in depth on how the feature actually works on the Solr end. Configurations and tweaking options in Solr and PHP are also discussed for advanced users to help them tweak the functionality as per their requirements.

This book will start with installation of Solr, adding, updating, and deleting documents on Solr using PHP and then exploring the features provided by the Solr search. We will explore the features provided by Solr such as faceting, grouping, boosting, and sorting of results. We will build a spell check and a query autocomplete feature provided by Solr. We will also look at advanced features for scaling search. This book will provide an end-to-end practical guide to building a full featured search application using PHP and Solr.

What this book covers

Chapter 1, Installing and Integrating Solr and PHP, introduces Solr and installs and integrates Solr with PHP on both Windows and Linux environments.

Chapter 2, Inserting, Updating, and Deleting Documents from Solr, provides practical examples on how to use PHP to add, modify, and delete documents from the Solr index.

Chapter 3, Select Query on Solr and Query Modes (DisMax/eDisMax), explains how to run basic search queries on Solr and use different query modes to run some advanced search queries.

Chapter 4, Advanced Queries – Filter Queries and Faceting, digs deeper into search queries and provides practical examples for running filter queries and facets using Solr and PHP.

Chapter 5, Highlighting Results Using PHP and Solr, explains how Solr can be configured for highlighting search results and provides practical examples in PHP for highlighting.

Chapter 6, Debug and Stats Component, explains how Solr calculates relevance, ranks the results of a search query, and explains how index statistics can be obtained.

Chapter 7, Spell Check in Solr, configures Solr for spell check and provides practical example of an autocomplete feature built using PHP and Solr.

Chapter 8, Advanced Solr – Grouping, the MoreLikeThis Query, and Distributed Search, goes in depth on some of the advanced topics in Solr and also explains how Solr can be scaled horizontally.

What you need for this book

You will need a Windows or Linux machine with Apache Web Server configured to run PHP scripts. A file editor for writing code and a web browser to check the output of code execution will be needed. We will be downloading, installing, and configuring Solr as required.

Who this book is for

This book is for PHP developers who need to build and integrate search into their applications. No prior knowledge of Solr is required. Understanding of object oriented programming using PHP would be helpful. Readers should be familiar with the concept of web applications.

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 the text are shown as follows: "Call the createPing()function to create the ping query."

A block of code is set as follows:

$config = array(
  "endpoint" => array("localhost" => array("host"=>"127.0.0.1",
"port"=>"8080", "path"=>"/solr", "core"=>"collection1",)
) );

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

cd ~/solr-4.3.1/example
java –jar start.jar

New terms and important words are shown in italics. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Select collection1 from the dropdown on the left-hand panel. Click on ping and you will see the ping time in milliseconds appear next to the ping link".

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 through 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/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 to our website, or added to any list of existing errata, under the Errata section of that title.

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.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Apache Solr PHP Integration
Published in: Nov 2013Publisher: PacktISBN-13: 9781782164920
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Jayant Kumar

Jayant Kumar is an experienced software professional with a bachelor of engineering degree in computer science and more than 14 years of experience in architecting and developing large-scale web applications. Jayant is an expert on search technologies and PHP and has been working with Lucene and Solr for more than 11 years now. He is the key person responsible for introducing Lucene as a search engine on www.naukri.com, the most successful job portal in India. Jayant is also the author of the book Apache Solr PHP Integration, Packt Publishing, which has been very successful. Jayant has played many different important roles throughout his career, including software developer, team leader, project manager, and architect, but his primary focus has been on building scalable solutions on the Web. Currently, he is associated with the digital division of HT Media as the chief architect responsible for the job site www.shine.com. Jayant is an avid blogger and his blog can be visited at http://jayant7k.blogspot.in. His LinkedIn profile is available at http://www.linkedin.com/in/jayantkumar.
Read more about Jayant Kumar