I would like to run a local install of a server to geocode close 47 million items. I am very grateful for the data provided (allCountries) and it looks like a great starting point.
Are there any resources on how to write queries against the data to get results similar to the geonames.org APIs?
E.g. my data has "San Francisco, CA". In the webservice I get the correct geocoded place (San Francisco, USA) as the first item. In the raw data there are 98 places called "San Francisco". How would an SQL query look that returns a result sorted similar to the geonames.org API?