I'm making an app that can search Metacritic (screen-scraper app). In the search box, I have an autocomplete function, which essentially does exactly what pressing "Search" would do, which is query Metacritic and populate a listview with the results. The problem is, since the app is a screen-scraping tool, it is not instant on autocomplete like Google.

Since the autocomplete is fired on keyup (every time the value of the text field changes essentially), since it is slow, when the user finishes typing, it updates the listview a bunch of times as it keeps searching, so it keeps changing which is quite annoying as it fetches the next results. Is there a good way to get around this?

I was thinking having it only query every other keypress, so that it wouldn't update as much and therefore wouldn't be as blinky.


This fix isn't necessarily perfect, but it helps a tremendous amount. What I did was:

a) Not fire the query until the length of the text field is at least 3 b) Fire every other keypress

This removed most of the blinking.

  • Your autocomplete function should kill the previous autocomplete thread (like a mutex): so you only run one autocomplete request at any one time. It would be clumsy to have it work every two characters. Commented Aug 25, 2013 at 19:17
  • I considered doing that; however, my app uses Apache Cordova so I am doing the requests via AJAX. Is it possible to kill previous AJAX requests?
    – Someone
    Commented Aug 25, 2013 at 20:36
  • 2
    If you can't kill the query add a timer. You don't need to launch query every time a key is pressed do the autocomplete only if the user wait a little. When people type an entire word fast you don't need every partial queries.
    – ColdCat
    Commented Aug 26, 2013 at 12:38
  • @Someone: you can kill the Ajax request with its abort() method Commented Aug 27, 2013 at 5:37
  • @Someone: You might also want to ask for technical advice on stackoverflow.
    – Brian
    Commented Aug 27, 2013 at 17:24

2 Answers 2


If auto-complete is slow, you can do several things:

  1. best option is to switch it off. Each user knows better than computer, what he wants to write
  2. Optimize software which is providing the auto-complete method. Common problem is, that values are read from files, then parsed, sorted, searched and after all that displayed every time a-c is accessed.
  3. Enable caching on auto-complete. Usually there are serious slowdowns, when auto-complete list should be read from the hard-drive or downloaded from Internet.
  4. Edited Enable pre-indexing. Let's have list of the a-c words extracted in the memory or quick access table in db with simple alphabetic or weight index, include background actualization according dynamic changes of the application. Enable most searched words first etc.

Unfortunately, you did not describe exactly what is the application with slow a-c, therefore it is hard to give more detailed answer.

Edited: Question is what makes your query slow. Target optimizations to that.

  • Well, believe it or not a lot of people asked me for an autocomplete feature. I can't really cache the list due to the dynamic nature of the program because I'm scraping.
    – Someone
    Commented Aug 25, 2013 at 18:04
  • 1
    Regarding answer number 1, what on earth do you base that claim on? Can you provide any research at all to back up that claim? Autocomplete, used correctly, is a great feature to help the user ask the right question, to ensure consistent data etc. etc.
    – Velkommen
    Commented Aug 28, 2013 at 12:12
  • 1
    As for number 1, keep in mind that even if autocomplete is not usable due to slow speed, the underlying technology is still useful. It can be used in auto-correction, in which after the user has submitted the whole query, the system can provide similar suggestions the same way a spell-checker offers alternative words with similar spelling or meaning. The value of having auto-complete in software is indeed dependent on it being reasonably fast. Example: Android ADT on Eclipse is a reasonably slow example.
    – rwong
    Commented Dec 21, 2014 at 23:34

Do you perform the search in a separate thread, so that it doesn't block the UI? If not, do this first.

Then, when results come in, don't show them if the user has already typed further characters. This should prevent the annoying multiple updates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.