Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apache Solr Search Patterns

You're reading from  Apache Solr Search Patterns

Product type Book
Published in Apr 2015
Publisher
ISBN-13 9781783981847
Pages 316 pages
Edition 1st Edition
Languages
Author (1):
Jayant Kumar Jayant Kumar
Profile icon Jayant Kumar

Table of Contents (17) Chapters

Apache Solr Search Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Solr Indexing Internals Customizing the Solr Scoring Algorithm Solr Internals and Custom Queries Solr for Big Data Solr in E-commerce Solr for Spatial Search Using Solr in an Advertising System AJAX Solr SolrCloud Text Tagging with Lucene FST Index

Chapter 8. AJAX Solr

In the previous chapter, we learnt how Solr can be used in an advertising system. We understood the working of an advertising system, its architecture, and the complexities involved in the implementation of the system. We also discussed some performance improvements in Solr with respect to the advertising system. In addition, we wrote a custom plugin for Solr intended for the integration of Solr with Redis (the key value memory store).

In this chapter, we will explore an advanced package known as AJAX Solr. We will first look at the architecture of AJAX Solr and then see how different functionalities of Solr such as pagination, search result faceting, customization of search results, and tag cloud can be performed using AJAX Solr. We will cover the following topics:

  • The purpose of AJAX Solr

  • The AJAX Solr architecture

  • Working with AJAX Solr

  • Performance tuning

AJAX is a JavaScript library that can be used to create interfaces in Apache Solr. It does not require any JavaScript...

The purpose of AJAX Solr


AJAX Solr is a Solr client developed using JavaScript. AJAX Solr facilitates interesting visualizations of a result set that includes widgets to display tag clouds of facets, filtering of results by date fields, and plotting of maps based on country code information. AJAX Solr can be integrated with any web application enabling the Solr-related operations to be performed directly on the Apache Solr interface, without the necessity to incorporate any language in between.

Ideally, any request on the Internet is received by a web application residing on the server, and Solr-related operations are forwarded to the Solr server for processing. This is shown in the following diagram. The request originating from the browser travels over the Internet to the web application residing on the web server. The web server then creates a Solr request and performs the required operation on the Solr server.

With AJAX Solr, the intermediary web application can be removed from the picture...

The AJAX Solr architecture


AJAX Solr follows the Model-View-Controller (MVC) pattern. The components of AJAX Solr are:

  • ParameterStore: This is the model of an MVC framework. This class stores the Solr parameters and hence the state of the application.

  • Manager: This acts as the controller in the MVC framework. It talks to the ParameterStore class and sends requests to the Solr server and delegates the response received to the widgets for rendering.

  • Widgets: Widgets act as views rendering the interface.

Note

AJAX Solr library can be downloaded from https://github.com using the Git client and the following command:

git clone https://github.com/evolvingweb/ajax-solr.git

You will need to install the Git client on your machine to execute this command. For Linux users, Git can be installed using the following command:

sudo apt-get install git

Windows users can download Git from the following URL and install it on their machines: http://git-scm.com/downloads.

This will create a folder called ajax-solr...

Working with AJAX Solr


Now that we have seen the architecture and components of AJAX Solr, let us go ahead and see how to implement it. We will download the default reuters index and build some features on top of it.

The reuters index is included as a part of code of this chapter. It can also be downloaded from http://public.slashpoundbang.com.s3.amazonaws.com/data-solr-4-index.zip.

Start with a fresh installation of Solr. Unzip the downloaded index and replace the data folder inside the <solr_installation>/example/solr/collection1 folder.

If the data folder does not exist, start Solr using the following command inside the <solr_installation>/example folder:

java -jar start.jar

Once Solr is running, simply shut it down using Ctrl-C on the Command Prompt.

This will create the data folder and the related configuration files inside the <solr_installation>/example/solr/collection1 folder.

We will also need to add and modify certain fields in our Solr schema. Open up the schema.xml...

Performance tuning


With AJAX Solr, we end up adding a lot of JavaScript and CSS to our pages. Though the searches would be faster as there is no server between the Solr server and the web browser, front-end optimizations can improve user experience. Here are some tips for that.

  • Controlling and minimizing server traffic: It is important to minimize the amount of data that flows between the Solr server and the web browser where AJAX Solr is in action. This can be achieved using the following:

    • Filtering at the server level: It is not a good idea to fetch the complete set of documents and the associated details from the server and filter them at the browser level so as to render only those results that match with the request. AJAX Solr performs filtering at the server level itself so that the transport channel doesn't get overcrowded with unwanted details. This also helps in minimizing the computation activities performed at the browser level.

    • Solr schema consideration: The Solr schema in AJAX...

Summary


In this chapter, we discussed AJAX Solr, which is an advanced JavaScript library that can be used to execute queries on a Solr server from a web browser. We saw the different components of AJAX Solr and discussed their internals. We also built a sample application using AJAX Solr and saw how the different components interact with each other. We also saw that, in addition to the display of the results received from Solr, Ajax Solr can be used for pagination, faceting, and building tag clouds.

In the next chapter, we will go through the benefits of using SolrCloud. We will see how SolrCloud can be set up and used to perform distributed indexing and search.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Apache Solr Search Patterns
Published in: Apr 2015 Publisher: ISBN-13: 9781783981847
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.
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}