Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | apachesolr-views-entity-view-modes-2.patch | 6.89 KB | dixon_ |
#2 | interdiff.txt | 2.14 KB | dixon_ |
apachesolr-views-entity-view-modes-0.patch | 6.01 KB | dixon_ | |
Comments
Comment #1
Nick_vhLooks 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.
Comment #2
dixon_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.
Comment #3
MiroslavBanov CreditAttribution: MiroslavBanov commentedI 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.
Comment #4
dixon_@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.
Comment #5
MiroslavBanov CreditAttribution: MiroslavBanov commentedYou 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.
Comment #6
Robert Castelo CreditAttribution: Robert Castelo commentedThis module provides Entity View modes for Apache Solr Views:
https://www.drupal.org/project/apachesolr_view_modes
Comment #8
ndf CreditAttribution: ndf at Dx Experts commentedAnother 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 :)