When searching for a word, the drop-down shows suggestions for anything else except that exact word.
The problem can probably be resolved here:
https://cgit.drupalcode.org/search_api_solr/tree/src/Plugin/search_api/b...
$autocomplete_terms = [];
foreach ($terms_result as $terms) {
foreach ($terms as $term => $count) {
if ($term != $incomplete_key) {
$autocomplete_terms[$term] = $count;
}
}
}
The term that matches the $incomplete_key is excluded.
From looking at the code, the problem probably also exists in search_api_solr 8.x-2.x as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | search_api_solr--exact-matches-8.x-3.0-beta3-2978909-7.patch | 682 bytes | tim-diels |
| #7 | search_api_solr--exact-matches-8.x-3.x-2978909-7.patch | 682 bytes | tim-diels |
| #6 | search_api_solr--exact-matches-8.x-1.x-2978909-6.patch | 697 bytes | recrit |
| #6 | search_api_solr--exact-matches-8.x-2.x-2978909-6.patch | 682 bytes | recrit |
| autocomplete_9.png | 70.05 KB | miroslavbanov |
Comments
Comment #2
miroslavbanov commentedComment #3
swentel commentedI've had the same use case for a client too. The exact word usually will return results so it's interesting to include it in the suggestions. Maybe this could be configurable in this way:
- always show the typed word
- show the typed word when count is > 0
Comment #4
swentel commentedOne could argue that this is a feature request of course, but I'm not debating on the status. FWIW, commenting out two lines lets the incomplete word show up
Comment #5
mkalkbrennerI'll accept patches for the suggested configs, but for 8.x-2.x (first).
Comment #6
recrit commentedAttached are patches for 2.x and 1.x to remove the "!=" check.
Comment #7
tim-dielsAdded patches for 3.x and 3.0-beta3
@mkalkbrenner I'm willing to work further on this with adding settings and config but want your opinion on where to start this and if we need this configurable or use this as standard.
Comment #8
mkalkbrennerObviously it's just a question of the feature definition.
I suggest to add a config option to the three autocomplete plugins we provide here. The patch should be straight forward. Have a look at \Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester\Suggester which already implements buildConfigurationForm().
Comment #9
mkalkbrennerComment #11
mkalkbrennerComment #13
theodorosploumisAlthough this issue is too old, I would like to mention that we have created the module search_api_autocomplete_improved to cover cases using Solr.