How to display other fields than Title in the suggestions?

Created on 13 June 2023, over 1 year ago
Updated 18 June 2023, over 1 year ago

Problem/Motivation

I setup a search view using search API and SOLR. I created an index for one single content type, and added 2 fields to it: the Title field and a Text field allowing unlimited number of values (we can name it FieldA). Autocomplete is active for the search field. When I start entering text in the search field, only the values of the field Title are displayed as suggestion, not the values of the field FieldA, even if the entered search query matches a value in the field FieldA.
Example: My node has values Title="Actinobacillus equuli", FieldA="Bacillus equuli; Shigella equuli". If I enter the text "Shigella" in the search field, autocomplete suggests "Actinobacillus equuli", which is indeed correct, since this is the Title of my node. But I would rather have autocomplete suggests the text "Shigella equuli" in order to match the query entered by the user. I guess this is feasible without using custom codes?

💬 Support request
Status

Fixed

Version

1.7

Component

User interface

Created by

🇧🇪Belgium pdau2571

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pdau2571
  • 🇧🇪Belgium pdau2571

    I understood my problem: I was using "Display Live results", which offers only options to use the entity label or a display mode of the entity.
    I use now "Retrieve from server", which is a better option for me. The problem now is that I'd like to suggest only complete names, and not names based on different fields. If I use for autocomplete the fields indexed as "fulltext", I get suggestions for entities which do not exist. Example: I have one entity with Title = "Abiotrophia defectiva" and FieldA = "Streptococcus defectivus". In the search field I get suggestions like "abiotrophia defectivus", which is wrong and doesn't return any result. The best option would be to use for autocomplete the fields indexed as "String". But this type of index field is not available in the options of the "Retrieve from server" suggester.

  • Status changed to Fixed over 1 year ago
  • 🇦🇹Austria drunken monkey Vienna, Austria

    It seems like what you want is “Display live results”, not “Retrieve from server”. (You want the autocomplete list results, not suggested search keywords – correct?) For displaying something other than the title, you can either create a new display mode for showing just that one field, or use hook_search_api_autocomplete_suggestions_alter() to override the display value.

    I hope this helps. Otherwise, please feel free to re-open this issue.

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

Production build 0.71.5 2024