Grouping documents by the function value

Imagine that you would like to group results not by using queries or field contents, but instead you would like to use a value returned by a function query. An example use case can be grouping documents on the basis of their distance from a point. Sounds nice right? Solr allows that and in this recipe, we will see how we can use a simple function query to group results.

Getting ready

In this recipe, we will use the knowledge that we've gained in the Grouping documents by the field value recipe in this chapter. Read the mentioned recipe before we continue.

How to do it...

  1. Let's start with the following index structure (just add the following fields 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.