# Search Personalization Discussion ## Main Steps 1. GET USER LOCATION --> Desired output - user's city and state. - Get current location using browser permission - lat/long - native browser support. More accurate, less prone to errors, requires explicit user consent. - As a fallback, consider approximating the location using IP Address - Could give an approx city or a lat/long (need to figure out). Less accurate and more prone to errors. Don't need explicit user content but use of VPN etc could cause issues. 2. GET CITIES CLOSE TO USER LOCATION - Current solution is to use static JSON mapping right once we get user location by city/state (Low effort, low flexibility, wont scale, accuracy low, short term) - Not going to use this solution since its very rigid and we rather just add the extra step and put it into the CMS - Store the mapping in the CMS (mumbai -> lonavala, karjat etc...). (Low effort, high flexibility, scalable, accuracy low, short term) - Dynamically fetch cities based on geolocation (high effort, med flexibility, scalable, accuracy high, long term). Add a promotion score to promote other cities. ### Store the mapping in the CMS (mumbai -> lonavala, karjat etc...). (Low effort, high flexibility, scalable, accuracy low, short term) Two alternatives for using the CMS - 1. Store the static mapping from city -> suggested cities 2. Using the Prismic "near" predicate to do this using lat/long at runtime/dynamically. Steps 1. Create a type for a City with fields like cityName, cityLat, cityLong, cityImage, numProperties ```json= { cityName: "Lonavala", lat: 9.1029310923, long: 1.129038102938, numProperties: 78, cityImage: "", ... } ``` 2. Create a type called City Suggestions ```json= { userCity: "Mumbai", title: "Getaways near you", suggestions: [ { city: <REF-TO-CITY>, distanceInKm: 100, distanceInHrs: 2.5 } ] }, { userCity: "Chandigarh", title: "Popular destinations for people from Chandigarh", suggestions: [ { city: <REF-TO-CITY>, distanceInKm: 100, distanceInHrs: 2.5 } ] }, { userCity: "Delhi", suggestions: [ { city: <REF-TO-CITY>, distanceInKm: 100, distanceInHrs: 2.5 } ] } ``` ### Dynamically fetch cities based on geolocation (high effort, high flexibility, scalable, accuracy high, long term). Add a promotion score to promote other cities. **IF you have the users location** Need an API that takes in usersLat, usersLong as an input, and returns a list of cities nearby with the distance in time. ```json= [ { city: "Lonavala", distanceInHrs: 1.5, distanceInKm: 100, numProperties: 76, cityPicture: "" }, ... ] ``` **IF NO user location** Show user most famous cities/locations. Currently we show nothing and just show the search dropdown.