When I add a filter in my View for a field, such as "Content datasource: Content type" and then save the view, this filter never gets applied and is not even passed to the Algolia backend. In the Algolia query log, I just see:
{
"attributesToRetrieve": "search_api_id",
"facets": [
],
"analytics": true,
"length": "6",
"offset": 0,
"query": "*"
}
with no filters. Tried adding a filter for a taxonomy term and ran into the same problem. Sending a query string works fine, so Algolia is connected. But Search API is not sending the filters for some reason.
Issue fork search_api_algolia-3352807
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
mpotter commentedIt appears that the SearchApiAlgoliaBackend::extractConditions function does not support `IN` queries. Would be good to document this as it prevents many common Views filters such as Content Type from working.
Comment #4
mpotter commentedAdded a patch that will at least support the "IN" operator when only one option is selected. This allows a basic Content Type filter to work when you just need a single content type since Drupal Views doesn't have an option for '=' operator on that field.
Comment #5
mpotter commentedComment #6
mpotter commentedUpdated patch to get the value rather than key of array.
However, while this patch works for Content Type, I'm not able to get it working for Taxonomy fields. I have a `field_topic` and with this patch it properly passes a filter of `field_topic:123` and in Algolia I have a node with a value of 123 for field_topic but the result isn't returned. I just get no results at all. So something is still not quite right with taxonomy filters.
Comment #7
mpotter commentedFound the bug problem with taxonomy terms. The existing code had a bug when adding the "AND" clause to the filter query. I think I can also see how to chain multiple terms using the AND operator, so will post another update for that soon.
Comment #8
mpotter commentedOK, I've updated the patch to work with any number of items with the IN operator. I think this is ready for review now.
Comment #9
davps commentedComment #10
nikunjkotechaCan we please have full steps to reproduce so we can review the patch and confirm the fix?
Details required
* Content type
* Taxonomy / reference fields
* Views, what field is the filter applied on
...
Also, how is this different from https://www.drupal.org/project/search_api_algolia/issues/3223351 ?
Comment #11
dieterholvoet commentedI also added support for NOT IN operators to the MR.
Comment #12
dieterholvoet commentedThis is a feature request, not a bug report, so there aren't any steps to reproduce here. If you're looking for an example: you don't need views for that, just creating a query in code is enough. Something like this:
Comment #13
nikunjkotechaIssue was created as bug, changed to feature request now. Thanks everyone for the work.