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. Imagine you could group documents on the basis of their distance from a point. Sounds good, Solr allows that and in the following recipe we will see how we can use a simple function query to group results.
In this chapter we will use the same index structure and test data we used in the Sorting results by a function value recipe in this chapter. We will also use some knowledge that we gained in the Using field values to group results recipe in this chapter. Please read them before continuing.