I have an exposed filter for search_api_views_fulltext but it was not passing its field ('search_api_viewed') to the autocomplete query. Things kind of blow up without any fields to search (search_api_autocomplete_autocomplete ends up throwing 500 errors on every character you type).

I tracked it down to search_api_autocomplete_form_views_exposed_form_alter assuming I would have fields in $view->filter[$field]->options['fields'], but mine was an empty array. I hadn't selected any fields to search on because in the filter settings it stated "Select the fields that will be searched. If no fields are selected, all available fulltext fields will be searched."

The patch sets the autocomplete field to search to 'search_api_viewed' in this case, but I guess really it should set it to an array of all available fulltext search fields.

Comments

drunken monkey’s picture

StatusFileSize
new1.35 KB

Please also see the duplicate in #1807618: Error if no search field is selected in views.

As you say, just using a field that might not even be there is just substituting one bug for another.
Also, it is notable that this doesn't happen for all setups, but (it seems) only for some webservers and if clean URLs are used. In my test environment, this works fine, which is why this went unnoticed.
Some webservers seem to collapse the two slashes, therefore messing with the parameter order.

Let's try it this way: just use a single space instead of an empty string, that should help.
Patch attached.

mh86’s picture

Status: Needs review » Reviewed & tested by the community

Patch from #1 fixes the problems for me. Thanks Thomas!

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Great, committed.

Status: Fixed » Closed (fixed)

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

shlapa’s picture

Does this mean that "Searched field" should be filled in Views? Why then we need fields check boxes in index auto complete settings?
This does not work for me. I have empty $fields variable in search_api_autocomplete_form_views_exposed_form_alter. And i get such URL in query field: /search_api_autocomplete/search_api_views_search/%20 (current dev version).