I know it's been discussed many times before, the performance impact of using entity_load() and entity view modes in Apache Solr searches (Apache Solr vs Search API etc). But sometimes that's what you need to do, and with Entity Cache it's not a big problem.

I don't know if there's another way to render view modes with Apache Solr Views (at least I didn't find one), so I wrote this simple plugin that I think is very useful.

I couldn't find a way to render Apache Solr Views without fields, so this plugin works around that. See the the code for more implementation details.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nick_vh’s picture

Status: Needs review » Needs work

Looks good and I do agree that it is less of an issue if you have entity cache and memcache for example.

however, I would add a warning that this should not be used if you do not have entity cache, as this will load random entities at all times and if you are using solr, this is something you want to avoid.

dixon_’s picture

Status: Needs work » Needs review
FileSize
2.14 KB
6.89 KB

That makes sense.

I simply put the warning in the title of the plugin if entitycache module is not installed. That will be hard to miss.
I also added some useful links to the modules this plugin depends on.

MiroslavBanov’s picture

Status: Needs review » Needs work

I get
Fatal error: Call to undefined function entity_view() in .../apachesolr_views_plugin_row_entity_view.inc on line 116
Note that "entity" module is not a requirement for "entitycache" module.

Also the plugin still uses fields, even though they don't appear to be needed.

The way the entity is loaded and rendered after the solr query result makes this useless for multisite search. A different approach would be to send the rendered content as a separate field on node index.

dixon_’s picture

Status: Needs work » Needs review

@Miroslav This new row style plugin depends on the Entity module. That's why you're getting the error message.
The mention of Entity Cache module is separate and just a recommendation to speed things up.

For multi site search this is not a good idea. Sending a rendered entity to the index itself is better for that purpose. However, this module solves a very valid and IMO a very useful purpose for single sites that for various reasons needs to load the entities.

MiroslavBanov’s picture

Status: Needs review » Needs work

You are right that this is useful and valid, but I don't see how this patch can be applied with fatal error. I suggest adding "entity" module dependency in info file, or doing a module_exists check in apachesolr_views_views_plugins().

Also, optionally, the soft requirement for "entitycache" module can be added to hook_requirements() to display a warning in the status report page.

Robert Castelo’s picture

Assigned: Unassigned » Robert Castelo
Issue summary: View changes
Status: Needs work » Fixed

This module provides Entity View modes for Apache Solr Views:

https://www.drupal.org/project/apachesolr_view_modes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ndf’s picture

Another contrib, totally based on patch #2
https://www.drupal.org/project/apachesolr_views_rendered_entity

Created it as a contrib to make it easier available for others to use it (instead of a patch).

Added everyone in this issue in commit-credit :)