I have users search queries, ads and cities.
The problem: I need to list search queries (phrases) that looks similar to the requested and make sure that they have ads in selected city.
For example: A user asked "buy a phone" and this query is similar to "buy a smartphone" and "buy an iphone". Then we show to user both
"buy a smartphone" and "buy an iphone" queries as similar because there is ads in a city that falls under these queries.
But when the user performs the query, say, in Moscow we list only "buy a smartphone" because there is no iphones in our ads in Moscow.
How do i accomplish this?