busbud/coding-challenge-backend-c — pull request #8 by hugow (2014-09-27 21:03:19+00:00)
Title: Make it work

+ Running here: http://infinite-mesa-5964.herokuapp.com/suggestions?q=m
#How it works
## startup
The whole table is loaded in one shot, synchronously (does not matter, it is startup) and parsed into a trie. The trie will find exact matches for a given word but also all words that start with the word being searched

## execution
+ The provided word is searched in the trie
+ A score is computed for all matched cities
+ The score includes information related to locations (long, lat), exact match of the string, and population of the cities (n will match New York if no other information is provided)

## mitigation
I must admit I am more than uncertain about this one. I think that in practice most mitigation would be done by load balancers. What I did was try to discover abnormal slowliness and return a 503 in this situation. I did not try to test what I did, it is possibly totally broken (well that's what should be assumed considering the fact that it is untested).

## shortcomings
+ not enough pre processing of the search string
+ a lot more tests should be written to determine if the scoring works optimally
+ I could have played with the scoring a lot more. It is "roughly" ok but definitely not good
+ I did not try to estimate the memory footprint of the trie thing
+ In practice, there should be a limit to the number of search results but I did not implement this
+ You can search "by text only" but you cannot search "by location only".