- last update
over 1 year ago 34 pass - 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for reporting this problem, and sorry it took me so long to get back to you!
I wanted to reply that this should already be working as described, at least for the “Retrieve from server” suggester, which should only suggest text values from the field for which autocompletion is executed.
However, when I wanted to verify that this is working as it should, it failed for me. Apparently, Core changed the form array structure for Views at some point, causing this functionality to break.
The attached patch should fix this again. Please test/review!(The ✨ Return a diferent field than the searched Closed: won't fix ticket seems unrelated, and like something that is also already implemented.)
-
drunken monkey →
committed 925a16b1 on 8.x-1.x
Issue #3273631 by drunken monkey: Fixed autocomplete on field-specific...
-
drunken monkey →
committed 925a16b1 on 8.x-1.x
- Status changed to Fixed
over 1 year ago 5:19pm 27 May 2023 - 🇦🇹Austria drunken monkey Vienna, Austria
Since I could reproduce the issue, I think I’m just going to commit this now, and assume you don’t have the problem anymore. No wonder, after almost a year.
Also, it seems like we already have a test for this, it just didn’t fail. For some strange reason, when the tests run the form structure is as expected, but it’s different when I try it myself in the browser, running the exact same code. I quickly gave up trying to make sense of that and just resigned myself to committing this without new tests. Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
10 months ago 1:02pm 28 February 2024 - 🇩🇪Germany stefan.korn Jossgrund
I suppose that this bug is still persisting. Still getting the suggestions from all fields provided in any exposed filter (if having multiple fields exposed though). Even if there is an exposed field for which no suggestions where activated, the suggestions for the other fields will be provided there too.
I could pin this down to:
https://git.drupalcode.org/project/search_api_autocomplete/-/blame/8.x-1...if I comment this line out, it seems to work like expected. But I am not sure what's up about the $input and the $single_field_filter here.
But the setExposedInput() - https://git.drupalcode.org/project/drupal/-/blob/10.2.x/core/modules/vie... - expects a string[] array. The actual implementation for the $single_field_filter case is not in line with this, at least my IDE is complaining.
- 🇩🇪Germany stefan.korn Jossgrund
Oh, it seems it depends on whether "Override used fields" in "Configure Suggester Retrieve from server" is configured or not.
If there are fields configured, that it will not work as expected (showing suggestions in all exposed fields) and if there are no fields configured, it works like expected.
- 🇩🇪Germany stefan.korn Jossgrund
Okay, once more.
It seems setFullTextFields() is possibly called twice in case the "override used fields" is configured:
https://git.drupalcode.org/project/search_api_autocomplete/-/blob/8.x-1....This is overruling:
https://git.drupalcode.org/project/search_api_autocomplete/-/blob/8.x-1....So maybe that is intended, but seems at least not intuitive.
Inserting
if (!$query->getFulltextFields()) { $query->setFulltextFields($this->configuration['fields']); }
here might solve this.