Allow filtering content views using search_api.

Created on 31 January 2025, 2 months ago

Problem/Motivation

I would like a full text search field available in content views (not search api index based views).

Is it possible to add a field to normal content views that does a full text search on the search API index and then gets back a list of entity ids to add or remove to the content view's search results?

I imagine that since a module like https://www.drupal.org/project/search_api_page exists that doesn't use views, this idea should be possible as long as search_api returns a value that views can use in an sql query.

I can't imagine something like this being worse than the available text searching options in views.

Steps to reproduce

Proposed resolution

Add a view filter plugin whose functionality is independent of a views query plugin.

Remaining tasks

Feature request
Status

Active

Version

1.0

Component

General code

Created by

🇺🇸United States trackleft2 Tucson, AZ 🇺🇸

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @trackleft2
  • 🇺🇸United States trackleft2 Tucson, AZ 🇺🇸
  • 🇦🇹Austria drunken monkey Vienna, Austria

    I already did something like this a few years ago for the Apachesolr module , see #254565-4: Integrate with Views front-end . It is definitely possible: you have to define a new filter plugin for the view, execute your search in there and then use the result item IDs to filter the view.
    The main problem with this approach is that it performs absolutely horribly so isn’t suited for anything but pretty small sites. Also, things like facets won’t work correctly as the search doesn’t contain the other filters you put on the view.
    Architecturally, it makes zero sense to do it this way and wherever possible you should just create a Search API view instead.

    That being said, in reality there are of course lots of specialized plugins provided for Views by other modules that aren‘t compatible with Search API views so there are views that cannot easily be rebuilt as a Search API view. If that is the case, and the site is small enough, then something like this could indeed make sense.
    I’m leaving this open for now. If enough people express their support and there’s someone willing to implement it we might actually add something like this.

Production build 0.71.5 2024