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

Controlling the number of terms needed to match


Imagine a situation where you have an e-commerce bookstore and you want to make a search algorithm that tries to bring the best search results to your customers. However, you notice that many of your customers tend to make queries with too many words, which results in an empty result list. So, you decide to make a query that will require a maximum of two of the words, which the user entered, to be matched. This recipe will show you how to do it.

Getting ready

Before we continue, it is crucial to mention that the following method can only be used with the dismax or edismax query parser. For the list of available query parsers, refer to http://wiki.apache.org/solr/QueryParser.

How to do it...

Follow these steps to control the number of terms needed to match:

  1. Let's begin with creating our index structure. For our simple use case, we will only have documents with the identifier (the id field) and title (the title field). We define the index structure...