Show suggested search in Bubble?

I’ve got an Input field that I’m using as a search box. When the user enters their search query, Bubble then pulls data from an external API and displays the corresponding data. (I don’t believe you can search external API’s via the ‘Search Box’ element, hence why I am building a custom search bar using the Input element)

What I’m wanting to build is something similar to Google’s autosuggest. For example, when the user starts to type “moni” they then see search suggestions like “monitors, monitor 144hz, monitor 4k, monitor cheap, etc”.

What is the most efficient way of accomplishing this?

My plan: Every time somebody searches something, Bubble will save that phrase to the Bubble DB. Overtime, I’ll start to have a large database of search queries to suggest to the user (also will be valuable data for me to know what users are looking for).

However, there are going to be lots of repeat/common phrases like “monitors”. So I’m thinking I should do some type of "Search X datatype, IF query/Thing exists, add +1 to the value (a secondary field I’d create), if it doesn’t exist, create a new thing.

image

I’d obviously want the most popular search queries being suggested so my thinking is I store/update a numerical value next to each search query. Is there a better/easier way?

1 Like