Book Image

Solr Cookbook - Third Edition - Third Edition

By : Rafal Kuc
Book Image

Solr Cookbook - Third Edition - Third Edition

By: Rafal Kuc

Overview of this book

This book is for intermediate Solr Developers who are willing to learn and implement Pro-level practices, techniques, and solutions. This edition will specifically appeal to developers who wish to quickly get to grips with the changes and new features of Apache Solr 5.
Table of Contents (18 chapters)
Solr Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Affecting document score using function queries


There are many situations where you would like to have an influence on how the score of the documents is calculated. For example, you would like to boost the documents on the basis of the purchases of it. As in, as an e-commerce bookstore, you would like to be showed relevant results, but you would also like to influence them by adding yet another factor to their score. Is this possible? Yes, and this recipe will show you how to do it.

How to do it...

Let's see how the document score is affected using function queries and the following steps:

  1. Let's start by defining the index structure by adding the following section to the schema.xml file:

    <field name="id" type="string" indexed="true" stored="true" required="true" />
    <field name="title" type="text_general" indexed="true" stored="true" />
    <field name="sold" type="int" indexed="true" stored="true" />
  2. The second step will be the example data, which looks like this:

    <add>
     &lt...