Without knowing how you are managing your data it is difficult to guess. If it's a database then indexing is usually part of the package, but if you are required to write your own then you need to create some sort of mapping that allows you to locate a record by looking up a keyword: something like
this[
^] perhaps.