I recently recreated the administrative media view with Search API. Everything was fine apart from the Media Type field isn't handled, and is treated as a standard string field. I have created a patch to resolve this for now (by adding entity:media_type to the views handler mapping and adding a callback for the options) - but it feels a bit wrong adding the function _search_api_views_get_media_types in search_api. What approach would be better?

Comments

nbaosullivan created an issue. See original summary.

nbaosullivan’s picture

StatusFileSize
new1.42 KB
drunken monkey’s picture

Issue tags: -Search API
StatusFileSize
new4.94 KB

Thanks a lot for reporting this issue!
After a quick look, it seems it should be quite simple to just support all kinds of bundle types generically in our filters. Please see (and test) the attached patch.
Optimally, of course, we’d also add test coverage for this. Would you be prepared to work on that? I fear, though, that we currently have no (direct) test coverage at all for search_api_views_data() hook (or should I call it an ecosystem already – it’s pretty complex, in any case, so could really use some tests). Shouldn’t be too hard to do, though. Just a lot of setup involved to get the necessary fields both in Drupal and in Search API.

drunken monkey’s picture

Component: General code » Views integration

Did you get a chance to test my patch? Can you confirm it works for you?
Tests would still be great, in any case.

nbaosullivan’s picture

I've just replaced my patch with yours and it works as expected for an exposed Media Type filter. Sorry I missed your previous comment - I don't have the time to do test coverage at the moment, but will return to help when I do. Thanks!

  • drunken monkey committed 76696e0 on 8.x-1.x
    Issue #3106515 by drunken monkey, nbaosullivan: Added support for Views...
drunken monkey’s picture

Status: Needs review » Fixed

Thanks a lot for reporting back, and even being generally open to providing tests.
I really shouldn’t do this, but anyways, as tests will be quite a bit of work probably: let’s just commit this now and, ideally, add tests later. If you get the time and still feel motivated, it would be awesome if you could create a new issue with tests for this functionality.
Committed here. Thanks again for your work!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

hchonov’s picture

We previously had used the filter "search_api_string" for bundles and now since we've updated from 1.15 to 1.16 our views using that filter for bundles are all broken.

Why wasn't there an update for this? How should we proceed now? Should we just manually update our views to use the new filter "search_api_options" or will there be an update provided?

ahaomar’s picture

I tried with search api along with Media but cant able to search from media. although from indexed fields are added from media type but still search not working. any special settings required ? I have media type along with fields title, description etc i want to search from these fields too.

please guide me settings, patch for that