Problem/Motivation
Search API Solr provides a "Retrieve results directly from Solr" option that can be useful for performance.
Currently, only the itemId is passed as a select field to the query.
Proposed resolution
Add a similar server setting and pass additional fields to the select statement. Possibly any fields marked as retrievable could be a starting point. Then, in the results builder populate the Search API Item with fields and their data from Azure.
Remaining tasks
I have not had time to work on building this out but I am providing an example of how I have implemented it for my own site.
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3558812-retrieve-results-directly-from-index-6.patch | 8.97 KB | kieran.cott |
Issue fork search_api_aais-3558812
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jacobsaw commentedExample with fields returned from a search view:
Comment #3
jacobsaw commentedComment #6
kieran.cottHi @jacobsaw,
I like your idea for this as a feature, so I have taken a pass at implementing this on the `3558812-retrieve-results-directly` branch in MR 33 and rolled this up as the attached composer patch.
Interested to see what you think and whether you have any further suggestions for improvement.
Comment #7
kieran.cottComment #8
jacobsaw commentedHi Kieran,
Thanks for taking this on! Really appreciate it.
Tested and it seems to work great, I set a debug point in SearchApiFieldTrait to confirm entity loading was being skipped.
One caveat I am leaving for anyone that encounters this issue in the future, if you have entity IDs with this solution you need to set them to integer rather than string or you will encounter an error with views if some items do not have values (TypeError: round(): Argument #1 ($num) must be of type int|float, string given in round() (line 173 of /app/docroot/core/modules/views/src/Plugin/views/field/NumericField.php)). I had not noticed this until adding the patch because my workaround was skipping reference fields.
I left some very minor suggestions for improvement in an MR that I tested as well. Once you get a chance to review those, I will move this forward.
Comment #9
kieran.cottThanks, Adam.
I've reviewed and approved your suggestions in the MR, happy for you to merge those in. :)
Comment #11
jacobsaw commented