To do this with any real search capability, you will need to have a database that can provide a place to store, relate and index meta data about each photo. Meta data is another term for "attributes" or search terms. The database contains a list of words (meta data) that are linked to each photo that is about that word. For example: meta data could be "John", "Doe", "1945", "New York City", "High School". Etc.
Each of these words represent an attribute of the photo. The photo is a High School graduation photo of John Doe from 1945, he lived in New York City at the time.
As you can see finding a determining the meta data can be fun, but also exhausting. I have a commercial database that I purchased to catalog and organize my photos. I am also a computer programmer, library professional and photographer so I have a background in this area, but also a budget that requires me to organize the thousands of photos I produce each year as well as the photos I collect of family items.
The first program I used before purchasing software was one that came on a CD ROM from a photo finishing company. I think WalMart still does it this way but I not sure. The photos have two components a small thumbnail for initial viewing and then a full-size version that can be used to see the detail.
I can't help you with specifics because I am not in the same user space as you are, but maybe this will give you a few ideas.