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" ...

Get Solr Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.