Result collapsing

Result collapsing groups similar search results together when displaying search results. The key or keys used for collapsing are configured by a search administrator and are based on either the documents content, or the document’s metadata.

For example, the result item below from a search of the complete works of Shakespeare shows that there are 21 very similar results to the Merchant of Venice: list of scenes result. This search has been configured to group or collapse all search results that are tagged with the same metadata value for a field recording the name of the play.

search result grouping result collapsing 01

Clicking on the 21 very similar results lists the 22 search results that form part of this group (the list of scenes result plus the 21 similar results). These can be sorted by providing a sort parameter in your More…​ link or by setting -sort in your query processor options. The sort options for this list of similar results are the same as for any normal search result sort.

search result grouping result collapsing 02

The initial search result can also be customized to show some additional information for the collapsed results.

The example result below, from another site groups sections of a publication together. The search result is configured to display the title of the first four collapsed items with a More…​ link which is the same as the 21 similar items link in the previous example.

search result grouping result collapsing 03

These (nested) collapsed results can be sorted using the -collapsed_docs_sort query processor option. This option will affect the set of collapsed results that are returned within the intial search response (controlled by the -collapsed_num_ranks option).

When to use result collapsing

Use result collapsing to:

  • Group different versions of a document into a single result

  • Group a set of related items into a single result (e.g. chapters in a book).