1

I want to be able to search for a an item in a multiple value field of a node and return the data of that specific value as the result.

I have a content type called 'Gallery'. 'Gallery' contains an image field that allows for unlimited values. Each value has an alt value that is exposed to Search API. I have a view using the "Search Views" module to filter the results from Search API.

I can successfully search for any 'Gallery' based on any of the alt tags of any of the images. The necessary data is exposed as fields to my view, such as: Gallery Photos: The image file. (indexed) | Gallery Photos » The image file.: File ID (indexed) (File ID (indexed))

but these fields only return data for the first image of that field in the Gallery.

I've searched high and low for a module or hack solution. No one has seemed to solve this. This seems like an important feature, because the way things are looking now, I would have to store each image as a separate node to be able to search for it individually. And that doesn't make sense for a lot of reasons.

Any help or direction would be greatly appreciated.

1 Answer 1

1

The problem you are facing is that Search API has a flat structure, so it cannot save multiple values for fields, as it would require a change in data structure which isn't done during indexing, since it will effect the already indexed results.

If you knew how many values you could get (fx max 3), then you could create entity properties that pointed to the values for image 2 and 3. Otherwise this is beyound the scope of what's possible right now with Search API module (at least to my knowledge.

2
  • Thanks Googletorp, I have come to the conclusion that this is probably not currently possible without a serious module that I dont have the time nor skill to build. To solve the same problem, I am approaching this issue from another angle. Create a 'file' view, create alt and title fields for files with the media module and then somehow sync the alt and title values from a node image field to the file. I've posted this question here: [drupal.stackexchange.com/questions/54497/…
    – Eric
    Commented Jan 4, 2013 at 20:35
  • I also was able to extract the title value using a 'file' view, the relationship: File: Content using Gallery Photos and the following php in a 'views php' field $node = node_load($row->nid); foreach ($node->field_gallery_photos['und'] as $photo){ if ($photo['fid'] == $row->fid){ $titleAtr = $photo['title']; break; } } return $titleAtr; but I cannot search on a php field and have posted this issue to the modules issue queue: drupal.org/node/1877186
    – Eric
    Commented Jan 4, 2013 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.