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.

Comments

MiroslavBanov created an issue. See original summary.

miroslavbanov’s picture

Issue summary: View changes
swentel’s picture

I'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

swentel’s picture

One 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


        $autocomplete_terms = [];
        foreach ($terms_result as $terms) {
          foreach ($terms as $term => $count) {
            //if ($term != $incomplete_key) {
              $autocomplete_terms[$term] = $count;
            //}
          }
        }
mkalkbrenner’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev

I'll accept patches for the suggested configs, but for 8.x-2.x (first).

recrit’s picture

Status: Active » Needs review
StatusFileSize
new682 bytes
new697 bytes

Attached are patches for 2.x and 1.x to remove the "!=" check.

tim-diels’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev
StatusFileSize
new682 bytes
new682 bytes

Added 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.

mkalkbrenner’s picture

Category: Bug report » Feature request
Status: Needs review » Needs work

Obviously 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().

mkalkbrenner’s picture

Version: 8.x-3.x-dev » 4.x-dev

mkalkbrenner’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

theodorosploumis’s picture

Although 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.