I'm working a a location search box and I was wondering if you guys could give me some help.
I've looked through so开发者_如何学JAVAme resources and managed to get working city search with spelling correction. It basically searches for exact matches, if none are found, it searches for double metaphone matches and limits them by the (levenshtein/length)<0.5 .
I'd like to implement a way to parse states (and if possible neighborhoods).
My question is:
Is there a way for MySQL to search for the city (and state)? What I mean is, is there a way for me to split the string and pass the parts to MySQL without knowing what each part is? (what part is city and which is state)
I'm thinking about this because I'd like to have spelling correction/guessing instead of just looking through the string with an array of correctly spelled states - similar to the way I have it with the cities.
There is probably an easy way to do this, I'm just mentally fatigued from getting the current city search working. I'd appreciate any help on this. Thanks.
Edit:
The tables,their fields and one sample row:
Cities:
States
you can concatenate the city and state columns in the DB and query on the combination like:
where concat(city, state) = city_state
精彩评论