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

Boosting words closer to each other


One of the most common problems that users are struggling with is how to improve the relevancy of their results while using Apache Solr. Of course, the relevancy tuning is in most cases connected to your business needs, but one of the common requirements is to have documents that have all the query words in their fields on top of the results list. You can imagine a situation where you search for all the documents that match at least a single query word, but you would like to show the ones with the entire query words set first. This recipe will show you how to achieve that.

How to do it...

  1. Let's start with the following index structure (add the following definition to your schema.xml file):

    <field name="id" type="string" indexed="true" stored="true" required="true" />
    <field name="name" type="text_general" indexed="true" stored="true" />
    <field name="description" type="text_general" indexed="true" stored="true" />
  2. The second step is to index...