Hello,

I can index fine Images as files in Search API. When displaying them in a search api view I don't get the regular drupal formatting options, such as displaying as thumbnail etc. How can I get these formatters?

Comments

giorgio79’s picture

giorgio79’s picture

Title: Image field formatters in Search API Views? » Image field formatters in Referenced Entity images in Search API Views?
Status: Closed (duplicate) » Active

Hmm, it looks like I am having problems with images in referenced entities. I am not getting the formatter option there, and can only index the image file, not the entire field.

MickC’s picture

Using 'Add Related Fields' only allows adding the image file entity field, not 'its' own fields - these can be added as further Related Fields.
Views can access the fields, but seems to handle them differently and there's different issues with each.

In my case the node is 'Event' with a referenced entity 'Artist' which has an image field.
I can add a single field related to the Artist 'Artist » Image » The file.'
Then I can add all the fields related to that e.g. 'Artist » Image » The file. » File name', 'Artist » Image » The file. » URL' - note that delta is not available.
Indexing works and the fields can be viewed in Solr.

Views can see the fields and they can be added but there are issues - of course using Relationships to add the image actually works, but the whole point of Solr to get the full performance benefit is to avoid using the database. This is as far as I can get using Solr field sonly:

'Artist » Image » The file' does not display data - commas appear if there are multiple values.
There's no Multiple Values option - this is needed because it is a multi value field.
Display offers an option to 'Show complete entity' , with a secondary option of 'View Mode'
If this actually worked it would be ideal.

Slightly better luck with the Artist » Image » The file. » URL' field, which can be rewritten to display a single image using #2 here https://drupal.org/node/1109318
However in my case because is is a multi value field, it fails to display if there is more than one.
This could be made to work if we could
a) force the index to only index the first delta value
b) enabled Multiple Values to work on the referenced image field
c) included the Delta field which could then be used as a filter

Seems this is close, if others can chime in on the above...

drunken monkey’s picture

Category: Feature request » Support request

a) force the index to only index the first delta value

You can do that with the "Aggregated fields" data alteration.

And yes, since the Field API formatters always need the full entity, it is not possible to use them with only the results data from Solr. As far as I can see, there's really no way around that (unless we want to store the complete entity in Solr, but then we'd have effectively re-implemented entity caching).

Also, I don't agree that "the whole point of Solr to get the full performance benefit is to avoid using the database". Solr has huge benefits (also performance-wise) even if you afterwards use the database to load the entities.
Or just use proper entity (and possibly other) caching instead of relying on Solr as a caching system.

legolasbo’s picture

Status: Active » Closed (outdated)

This issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.