# HowTo do autocompletion?

**URL:** <https://discuss.elastic.co/t/howto-do-autocompletion/14792>\
**Category:** Elasticsearch\
**Created:** [December 10, 2013, 2:02pm UTC](https://discuss.elastic.co/t/howto-do-autocompletion/14792 "2013-12-10T14:02:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OhNo](https://avatars.discourse-cdn.com/v4/letter/o/34f0e0/32.png) [@OhNo](https://discuss.elastic.co/u/OhNo)\
**Post date:** [December 10, 2013, 2:02pm UTC](https://discuss.elastic.co/t/howto-do-autocompletion/14792/1 "2013-12-10T14:02:04Z")

</div>

Hi all,

I have indexed some of my person objects. Now i want to implement an autocompletion function in my search, so the user start typing "Da" which triggers a search and my Searchhits contains the String "Daniel", "Daniela" and "Darius" for example. There is a Suggestion API which can be used separately but also within searches, what should i use? I already have a solution but, this returns me all person objects, not only the Strings, so how can i know that the firstname or lastname matched???

Please post a JAVA example, not a Rest example because i use the java Api.  
Thanks for any help, elasticsearch really drives me crazy...☹

---

<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:** [July 6, 2017, 2:02am UTC](https://discuss.elastic.co/t/howto-do-autocompletion/14792/2 "2017-07-06T02:02:14Z")

</div>


