0

I'm currently working on a small scale personal project using peewee and sqlite3 to store data locally within the app in a database as a fun way to increase my coding knowledge & skills.

It's mostly static data and the main usage would be to reflect information linked to certain keys. As an example:

  1. Tennis: Tennisball, gravel, 2 players
  2. Football: football, grass, 22 players
  3. American football: american football, grass, 22 players
  4. Basketball: basketball, wood, 10 players
  5. Volleyball: ...
  6. ....
  7. ......

One thing I'd like to implement is a real time search which searches for either 1) only the key words before the ':' (tennis, football, basketball, american football,..) and/or 2) searches all data for that exact string.

But I want to have the search function provide you with the remaining key words in real time. Meaning every time I type a letter, I want it to show you the remaining key words it matches with. And it is exactly this feature I can't seem to find a solution to.

Example:

Typing 'b' will show you all key words with a 'b' in it. While with each new letter you type, it should further truncate the results further. 'Ball' will generate keys numbered 2, 3, 4 & 5 in the example on the top. While typing 'football' generates only keys numbered 2 & 3.

I hope this is somewhat making sense. I need some guidance or sense of direction where to look for something I'd like to implement as I have been unable to find any similar question.

Edit:

I saw this was flagged several times as duplicate question however I did search on this site and the internet for solutions to this but found none. It is not the autocompletion à la Google I'm going for. If it is a duplicate, I would be very happy if there would be a link to the answer to my question.

Kay Jay
  • 41
  • 1
  • 4
  • Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – R Nar Jun 08 '16 at 19:08
  • Even if these aren't quite exact dup matches they should get you started. I did a Google Search for autocompletion Python and there are a lot of resources. Start there and then when have a coding question come back – PyNEwbie Jun 08 '16 at 19:12
  • looks to me like you need to implement a kind of search tree, like search engines do, good luck – DevLounge Jun 08 '16 at 19:35
  • Many thanks for the suggestions. I read all the intros to this website. However I do not believe this is a duplicate at all. I do not want an auto-completion feature. I want it to, in real-time have my list of possible matches appear in a separate location and truncate those results. I am very much aware of the google autocompletion however it's not what I was going for. – Kay Jay Jun 09 '16 at 17:21

0 Answers0