Book Image

Mastering Apache Solr 7.x

By : Sandeep Nair, Chintan Mehta, Dharmesh Vasoya
Book Image

Mastering Apache Solr 7.x

By: Sandeep Nair, Chintan Mehta, Dharmesh Vasoya

Overview of this book

Apache Solr is the only standalone enterprise search server with a REST-like application interface. providing highly scalable, distributed search and index replication for many of the world's largest internet sites. To begin with, you would be introduced to how you perform full text search, multiple filter search, perform dynamic clustering and so on helping you to brush up the basics of Apache Solr. You will also explore the new features and advanced options released in Apache Solr 7.x which will get you numerous performance aspects and making data investigation simpler, easier and powerful. You will learn to build complex queries, extensive filters and how are they compiled in your system to bring relevance in your search tools. You will learn to carry out Solr scoring, elements affecting the document score and how you can optimize or tune the score for the application at hand. You will learn to extract features of documents, writing complex queries in re-ranking the documents. You will also learn advanced options helping you to know what content is indexed and how the extracted content is indexed. Throughout the book, you would go through complex problems with solutions along with varied approaches to tackle your business needs. By the end of this book, you will gain advanced proficiency to build out-of-box smart search solutions for your enterprise demands.
Table of Contents (14 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

JavaScript Client API


JavaScript client is very easy, simple, and straightforward. We don't need to create any client to connect to Solr. Also, no packages need to be installed for the JavaScript client. JavaScript sends the request to Solr using XMLHttpRequest. Solr processes the request and returns the response in JSON format, which can easily be parsed in JavaScript. We don't need to configure the wt response parameter as Solr, by default, returns the response in JSON format.

Example: Configure hostURL= http://localhost:8983/solr/techproducts/select in JavaScript as follows:

<html>
<head>
<title>Solr Javascript API Example</title>
<script language="Javascript">
//main function called when clicking on search button
function search() {
  //Solr search url
  var hostURL='http://localhost:8983/solr/techproducts/select';
    var xmlHttpReq = false;
    var xmlHttpClient = this;

  // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpClient.xmlHttpReq...