Reader small image

You're reading from  Apache Solr High Performance

Product typeBook
Published inMar 2014
Reading LevelIntermediate
Publisher
ISBN-139781782164821
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Surendra Mohan
Surendra Mohan
author image
Surendra Mohan

Surendra Mohan, who has served a few top-notch software organizations in varied roles, is currently a freelance software consultant. He has been working on various cutting-edge technologies like Drupal, Moodle, Apache Solr, ElasticSearch, Node.js, SoapUI, and so on for the past 10 years. He also delivers technical talks at various community events like Drupal Meetups and Drupal Camps. To find out more about him, his write-ups, technical blogs, and much more, go to http://www.surendramohan.info/. He has also written the books Administrating Solr and Apache Solr High Performance published by Packt Publishing and has reviewed other technical books such as Drupal 7 Multi Site Configuration and Drupal Search Engine Optimization, as well as titles on Drupal commerce, ElasticSearch, Drupal related video tutorials, titles on OpsView, and many more. Additionally, he writes technical blogs and articles with SitePoint.com. His published blogs and articles can be found at http://www.sitepoint.com/author/smohan/.
Read more about Surendra Mohan

Right arrow

Scoring


You might come across scenarios where your search engine should be capable enough to search and display appropriate search results from a large collection of documents, especially when the visitor is not really sure of what he/she intends to search.

In this section, we will learn about the basic concepts of how Solr ranks the documents and later step into how we can tweak the way Solr ranks and renders the search results.

We must keep in mind that the score is not a term that holds an absolute value; instead, it holds a relative value with respect to the maximum score and is normalized to fall between 0 and 1.0. The primary objective behind implementing a score is to narrow down the field list to a smaller set by mapping the fields together and then inject the smaller set to the search engine. Doing so helps the search engine understand the request better and serve the requester in a more appropriate way.

To understand the preceding objective better, let us assume we have an event that...

The dismax query parser


Before we understand how to boost our search using the dismax query parser, we will learn what a dismax query parser is and the features that make it more demanding than the Lucene query parser.

While using the Lucene query parser, a very vital problem was noticed. It restricts the query to be well formed, with certain syntax rules that have balanced quotes and parenthesis. The Lucene query parser is not sophisticated enough to understand that the end users might be laymen. Thus, these users might type anything for a query as they are unaware of such restrictions and are prone to end up with either an error or unexpected search results.

To tackle such situations, the dismax query parser came into play. It has been named after Lucene's DisjunctionMaxQuery, which addresses the previously discussed issue along with incorporating a number of features that enhance search relevancy (that is, boosting or scoring).

Now, let us do a comparative study of the features provided...

Function queries


A function query can be defined as a user-specified Solr function that is usually mathematical in nature and is supported by dismax, edismax, and other standard query parsers. It enables you to generate a relevancy score based on the actual value of one or more numeric fields. Since function queries are technical, they are so robust that they can be used in instances where the queries' context comes into picture. The instances include searching, filtering, faceting, sorting, and so on.

Now, we will understand a few of the ways by which we can incorporate a function query into our Solr instance. They are as follows:

  • The dismax query parser (the bf and boost parameters): As we already discussed earlier in this chapter, the bf and boost parameters boost the user query score by adding or multiplying the function query. In the upcoming section, we will learn how to derive a function query in depth using a few examples.

  • The boost query parser: Unlike the boost parameter in dismax...

Summary


In this chapter, we covered advanced topics associated with scoring, function queries, and so on. We began with a background on Lucene scoring, different terminologies and their significance, and learned query-time and index-time boosting. We also learned how to troubleshoot your queries and scoring and headed towards more complex and important topics such as different ways to use the dismax query parser and how it is better than Lucene's DisjunctionMaxQuery. Apart from this, we learned the ways of boosting our search based on varied circumstances, for instance, automatic phrase boosting and partial phrase boosting, what are the boost queries and boost functions and how can they be used. We also covered advanced concepts of function queries such as field and function references, different mathematical operations, including geometric or trigonometric operations, and how to implement formulas such as logarithm, reciprocal, and linear in an intention to boost your function queries.

In...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Apache Solr High Performance
Published in: Mar 2014Publisher: ISBN-13: 9781782164821
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 €14.99/month. Cancel anytime

Author (1)

author image
Surendra Mohan

Surendra Mohan, who has served a few top-notch software organizations in varied roles, is currently a freelance software consultant. He has been working on various cutting-edge technologies like Drupal, Moodle, Apache Solr, ElasticSearch, Node.js, SoapUI, and so on for the past 10 years. He also delivers technical talks at various community events like Drupal Meetups and Drupal Camps. To find out more about him, his write-ups, technical blogs, and much more, go to http://www.surendramohan.info/. He has also written the books Administrating Solr and Apache Solr High Performance published by Packt Publishing and has reviewed other technical books such as Drupal 7 Multi Site Configuration and Drupal Search Engine Optimization, as well as titles on Drupal commerce, ElasticSearch, Drupal related video tutorials, titles on OpsView, and many more. Additionally, he writes technical blogs and articles with SitePoint.com. His published blogs and articles can be found at http://www.sitepoint.com/author/smohan/.
Read more about Surendra Mohan