Hi I am trying to implement simple search functionality for my app.
I just used ilike
function for this.
Then I want to keep user’s search history and want to implement search suggestion.
But I actually don’t know where to start.
First, create search_terms table with term and counter.
Whenever user tries to search, check if that term is already in the database,
if yes, increase counter by 1, if not, save that term in database with counter = 1
For search term suggestion,
query = from st in SearchTerm, order_by: [desc: st.counter], limit: 10
Repo.all(query)
Problems
- SearchTerm table will be filled with meaningless word or words like
asdasd3
or else - Words with wrong spelling will be saved also(aple, orenge…)
- SearchTerm table will be anyway getting bigger very soon.
And also maybe I have a performance issue?
So Can you guys give me some advice?
Thanks!