Problem/Motivation

Currently the module uses /core/modules/search/src/Controller/SearchController.php to render search pages.

The core controller doesn't call buildResults() unless the 'keys' parameter is present.

When filters are exposed, folks who are searching might want to only use the filters and not provide a keyword.

Proposed resolution

Lightweight approach to get around the requirement similar to how the node module search works to allow advanced searches without a keyword:

  • Add a configuration option to allow for filter only searches
  • Add an empty "keys" param to the query string. e.g. ?keys=
  • Update docroot/modules/contrib/vertex_ai_search/src/Service/VertexSearchManager.php from line 260 to (or use the configuration option to determine whether to continue)
    if (!empty($searchKeys)) {
      // Set Keywords to be used in request query.
      $request->setQuery($searchKeys);
    } 
  • Update docroot/modules/contrib/vertex_ai_search/src/Plugin/Search/VertexAISearch.php and add (with logic related to the new configuration setting)
    /**
     * {@inheritdoc}
     */
    public function isSearchExecutable() {
      // Allow search without keywords if configured.
      return TRUE;
    } 
    
  • Adjust the no keywords message in docroot/modules/contrib/vertex_ai_search/vertex_ai_search.module if the search is configured to allow filter-only searches (likely want to check that a filter value exists)

Alternatively, this module could alter the route for the search controller and have its own logic.

Command icon 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

jastraat created an issue. See original summary.

jastraat’s picture

It appears that at least in our case, when submitting a search without keywords, the "keys" parameter is already appended empty within the query string, so the lightweight approach is viable.

jastraat’s picture

Discussed with Timo and suggest that when this new "Allow search without keywords" is checked that the "No keywords specified message" field is disabled using states.

jastraat’s picture

Last discussion we considered repurposing the existing No keywords specified message to include when there are no keyword and no filters.

jastraat’s picture

Status: Active » Needs review

  • timozura committed c4912306 on 1.0.x authored by jastraat
    Issue #3588680: Initial attempt to support filter-only searches
    
timozura’s picture

Version: 1.0.x-dev » 1.11.0
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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