This module adds support to index multiple view mode renderings on an entity, instead of just one.

Configuration

There is very little to configuring this module. Enabling it will add a new data alteration callback in an index called "Multiple entity views". Select all the view modes in its option list for the indexed entity. When processing the data, Search API will render the entity item in each view mode, storing the rendered HTML as an item in your indexed record.

The advantage to this is that you can bypass hooking, loading, and rendering entities for data because you know they are already cached/stored in your result set. A good example of this would be a search form with search presentation(s) or entities rendered in sidebars, footers, or mobile devices.

How to Use

In your code, when dealing with a search response, there should be new fields returned. Each field will be called "view_mode_" with the view mode name affixed to the end.

For example, if you indexed Full, Search, List, and Mobile, you should see these in the results response per item:

  • view_mode_full
  • view_mode_search
  • view_mode_list
  • view_mode_mobile

Since this does render entities when processing, it is best to reduce the amount of items indexed per run to an acceptable limit based on your memory settings.

Views Integration

You can add the stored field to Views displays if your backend supports "Return all data' options (for example, Search API Solr). There is a custom handler for Views provided by this module that will show the result, including HTML.

Backend Support

So far, this module has been tested and known to work well with these backends:

  • Apache Solr
  • ElasticSearch

Drupal 7

If you are using Drupal 7, the version of this module is a port of Search API Solr Multiple View Modes with fixes to remove hard references to 'solr' - as this functionality can work with any backend.

Supporting organizations: 
Development

Project information

Releases