Search API Views don't always use exposed filters for the search - they can also use contextual filters which grab the search terms from URL.

This module only works in the former case. To accommidate the latter, it should be possible to set the links to change the URL argument instead of the query string in such cases.

Incidentally, Search API Spellcheck module has a similar problem (#1425766: Spelling suggestions not display in View). The module logic is very different (using views handlers) but some of the issues apply to both cases. A key difference will be, that fix for that module will probably require sniffing the type of view automatically while this will probably require a manual setting per current search block.

Comments

alanom’s picture

Here's a patch. It:

  • Adds a field to the settings where people can, if needed add a number for the URL argument of the search terms a specific current search block applies to
  • If this is set, it swaps the new search terms for the specified argument, while keeping the query string the same.
  • (if, as by default, it's not set, everything works exactly as before)
alanom’s picture

small correction, added default value

Johnny vd Laar’s picture

Thank you, I'll look into the patch and submit a new version hopefully in the coming weeks

Johnny vd Laar’s picture

Status: Active » Fixed

I've added a slightly modified version of your patch:
https://drupal.org/commitlog/commit/33676/fda2ee67346adc20bb5e8746758e11...

Thanks for the help. Can you check whether it works?

chirhotec’s picture

@Johnny,

You removed the $new_search_terms, in favor or explicitly setting $args[$arg_position] = implode(' ', $keys_copy). However, you didn't update $params['search_api_views_fulltext'] = $new_search_terms;. This generates an error for searches that are using the original exposed filters.

Here's a patch that undoes that change.

I have not tested whether contextual filters are actually working with your update.

Johnny vd Laar’s picture

Thank you a lot. I've committed your fix.

Status: Fixed » Closed (fixed)

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

alanom’s picture

Yup, works. Had to re-enter the config form data after updating, but after doing so, it works.