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

**URL:** <https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288>\
**Category:** Elasticsearch\
**Created:** [November 7, 2016, 11:12pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288 "2016-11-07T23:12:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![totessusan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/totessusan/32/13028_2.png) [@totessusan](https://discuss.elastic.co/u/totessusan)\
**Post date:** [November 7, 2016, 11:12pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288/1 "2016-11-07T23:12:05Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [November 7, 2016, 11:28pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288/2 "2016-11-07T23:28:17Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html)

---

<div class="post-metadata">

**Author:** ![totessusan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/totessusan/32/13028_2.png) [@totessusan](https://discuss.elastic.co/u/totessusan)\
**Post date:** [November 7, 2016, 11:30pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288/3 "2016-11-07T23:30:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [November 8, 2016, 5:46pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288/4 "2016-11-08T17:46:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![totessusan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/totessusan/32/13028_2.png) [@totessusan](https://discuss.elastic.co/u/totessusan)\
**Post date:** [November 8, 2016, 5:58pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288/5 "2016-11-08T17:58:27Z")

</div>

These are great tips! Thanks a bunch, @msimos! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 6, 2016, 5:58pm UTC](https://discuss.elastic.co/t/is-there-some-way-to-mimic-a-google-like-typeahead-search/65288/6 "2016-12-06T17:58:29Z")

</div>

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