Module extension to prevent the entities being loaded from solr results in views by a query setting.
The well know module search_api_solr (https://www.drupal.org/project/search_api_solr) force the entities to beign loaded from the solr results in views, ignoring if the user only want to display specific fields that are already indexed in solr. In that case we can improve the performance of view generation avoiding the load of the entities.
- Clone the repo into the drupal module folder
- Activate the module in the drupal admin section extend
- Set the solr server backend to "Solr Pro"
- Move the index to the new server and re index them
- Go to the view
- Open the advance query setting dialog
- Check the option "Skip entity load"
- Specified the indexed fields you want to use in the view (If the field is set as excluded for render then it will not be available in the view)
Note: In the twig file for the view you will find the fields in the row object, for example:
<li class="alpha-section__list-item">
{% if title %}
<h3>{{ title }}</h3>
{% endif %}
<ul class="alpha-section__sublist">
{% for row in rows %}
{%
set row_classes = [
default_row_class ? 'views-row',
]
%}
<li>
{% set result_row = row.content['#row']|obj_to_arr %}
{% set name = result_row['entity:authors/person_name'][0].getText() %}
{% set url = result_row['search_api_id']|replace({':und': ''}) %}
{{ link(name, url) }}
</li>
{% endfor %}
</ul>
</li>
- Drupal 8.X
- Search API Module (https://www.drupal.org/project/search_api)
- Search API Solr Module (https://www.drupal.org/project/search_api_solr)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.