Issues with Drupal and Apachesolr

Apache Solr and Drupal 7Recently I dealt with the problem of displaying Apachesolr_Search module results inside a Drupal 7 site.

The Apachesolr_Search module is a terrific module. Using it we have been able to create multiple search pages and blocks that do not effect Drupal’s database performance. But even great modules can have problems: we’ve been having issues displaying the generated search results…

To make the search results display nicely, we decided to try a different module: display suite search. In multiple discussions on drupal.org I found that only ds_search avoids additional node_load while displaying search results nodes. I decided to install the module and try it.

It was a great surprise to me that, in fact, additional node_load is not avoided. I created a new discussion on drupal.org and asked the maintainer of ds_search to fix the issue. He stated that this was “by design”…  Be warned that multiple node_loads on a search_results page can create a big performance hit for sites that have a lot of content to search.

To display search results without node_load, we decided to store a rendered node or node object inside the solr index. Saving node display for me is the preferred way because it saves on the solr index’s size. But there is an issue with this solution: when we rebuild search index node_view using the current administration theme, additional styling or theming must be done for the theme (unless the user and admin themes are the same).

When we store the node object, we can display the node using the current theme and no additional styling is needed, but the solr index will become much bigger than before. It will not effect search speed because the node object will be stored in a special field which is not used during search.

So here are your choices to avoid node load:

1) Store node display: PROS: less solr index, avoidance of node_view(). CONS: additional styling may be necessary.
2) Store node object: PROS: no additional styling needed. CONS: executed node_view(),  a bigger solr index.

Also, you must choose node display to use.

Note that these settings are available only for search pages. I hope soon I will add them to search blocks as well!

Here is a link to the Apachesolr display module.