I am using Search autocomplete with an exposed filter from Views. For autocomplete, I want to restrict the search to just the title field even though the actual search uses more fields than that.
It seems that all fields configured (in Views) for the exposed filter are searched. It does not matter what configuration I use on admin/config/search/search_api/index/*/autocomplete/search_api_views_*/edit
: I can select a different "Views display" or I can select different fields in "Override used fields" but these settings seem to be ignored.
Am I doing something wrong or is this a bug?
Looking at the code from search_api_autocomplete_form_views_exposed_form_alter()
I do not see that the configuration is being used anywhere. I suppose I can use hook_search_api_autocomplete_views_fulltext_fields_alter()
to fix this. Is that what I am supposed to do?
Tested with 7.x-1.4 and 7.x-dev.
Comments
Comment #2
benjifisherIn case someone else finds it useful, here is the code I used:
Comment #3
drunken monkeyIf you look at the beginning of
search_api_autocomplete_autocomplete()
(around line 30), you'll see that as long as fields are set in the autocomplete options, those passed from somewhere else will be completely ignored.However, are you maybe using an older (more than a year) version of the "Database search" module? See #2483123: Narrowing autocomplete suggestions to one field – we had the problem there that the fields were completely ignored.
Comment #4
iamweird CreditAttribution: iamweird commentedYes, but it's
$search->options['suggester_configuration']['fields']
, not$search->options['fields']
for me (I've got 7.x-1.5).Comment #5
marinex CreditAttribution: marinex commentedHi I have same issue:
search_api_db 1.7
search_api_autocomplete 1.6
It does not respect settings on a field in the viewsfix.:My issue is related to the getAutocompleteSuggestions
After some digging I notice that code below override views field options:
File: SearchApiAutocompleteServerSuggester.php
It is needed to fix!After setting of configuration on administration all works as designed! Sorry!
Comment #6
marinex CreditAttribution: marinex commentedAll works as designed!