Is there some way to mimic a Google-like typeahead search?


(Susan Liu) #1

I've read almost every Elasticsearch documentation on suggesters, and I have yet to find what I'm looking for. Is there any way I can mimic a Google-like typeahead search?

My potential plan is to try these steps:

  1. create a separate index just to record all possible searches that users perform on my site and store them into the index with date, time, input
  2. delete content after a month to maintain reasonable storage and relevance
  3. within my search bar,i want to be able to search the content of my files AS WELL AS everyone else's searches that seem relevant and possibly boosting certain results

Has anyone tried this? Does anyone see a setback for this - in terms of memory/security/performance/etc?

P.S. I do not want Results Suggest (results with top hits). I want Search Suggest (what others have been searching for).

Thanks in advance!


(Mike Simos) #2

You can use edge_ngrams on the field you're recording the searching being performed:

https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html


(Susan Liu) #3

Thanks, @msimos! I guess my main question is if making that separate index just to retain other people's searches is a good idea...performance-wise...or if there's a method that is better than this?

It's interesting to me that I haven't come across anyone doing this, so I'm a bit skeptical.


(Mike Simos) #4

I think this sounds fine assuming your index is deduping what people are searching. And you may want to record how many times a phrase is searched for and using that to boost results. Using completion suggest will be more performant over edge ngrams because the data structures are built in memory.


(Susan Liu) #5

These are great tips! Thanks a bunch, @msimos! :slight_smile:


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.