Jump to content
glendango

Best Practice for searching on a website

Recommended Posts

Posted (edited)

Hi, i'am looking for best practices in 2019 for Search on a website.  Very similar to rightmove / zoopla etc. 

1) They allow the user to search by county / postcode / town.  How is this list populated in the drop down?  is it a list of towns  in a plugin  which are then used as variables to populate the mysql select query,, or is it ajax populating the search input with a call to the db...

Reason iam confused it i know of a site with no property in a certain area but the list still predicts the area ...i.e. if no matching address is in the db how is it populating?  

 

2)  they also have a search function that once the user has arrived on the page by postcode..users are able to search 1/4 mile 1/2 mile radius etc from the  postcode for other properties...   how is this working?  

thx for your time in advance .   

in the jpeg i show the search box...when user types 'lon'    it brings up everything with lon in title i.e london, londonderry, long meadow  etc 

 

onmark.JPG

Edited by glendango

Share this post


Link to post
Share on other sites
1 hour ago, glendango said:

1) They allow the user to search by county / postcode / town.  How is this list populated in the drop down?  is it a list of towns  in a plugin  which are then used as variables to populate the mysql select query,, or is it ajax populating the search input with a call to the db...

Reason iam confused it i know of a site with no property in a certain area but the list still predicts the area ...i.e. if no matching address is in the db how is it populating?  

They have a big database of locations. Probably purchased from and/or subscribed to a service that tracks stuff like that so they don't have to try to stay up to date themselves.

Quote

2)  they also have a search function that once the user has arrived on the page by postcode..users are able to search 1/4 mile 1/2 mile radius etc from the  postcode for other properties...   how is this working?  

They know the latitude and longitude of an address, also probably from a third-party service (eg, Google Maps). A postcode has a location too, though it's obviously not quite as precise. Then they can do some pretty simple math to estimate the distance between the two points.

  • Like 1

Share this post


Link to post
Share on other sites

They have a big database of locations. Probably purchased from and/or subscribed to a service that tracks stuff like that so they don't have to try to stay up to date themselves.

 

interesting.   so do you think they use Ajax to get the locations from a database or would it be an API....   

once a user selects  e.g.  Islington, London    .

does this then add that as a $variable to a select statement to the database to create a list of properties on the next page ? 

$location = islington

select * from table where $location 

 

Share this post


Link to post
Share on other sites

If ($lat, $lng) is the centre of the postcode area, then this will find the locations of properties within $d Km

select lat, lng from properties where 
pow(lat-$lat, 2) + pow((lng-$lng)*cos(radians($lat)), 2) < pow($d/110.25, 2)
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

nice,,so i can set the radius from the selected lat/long of the properties. Rightmove only lets you search minimum 1/4 mile radius  which is to large...

1/8 mile be ideal.  

Edited by glendango

Share this post


Link to post
Share on other sites
36 minutes ago, glendango said:

interesting.   so do you think they use Ajax to get the locations from a database or would it be an API....   

AJAX is a way for the browser to get something from the server without having to refresh the page. An API is merely what tells two things how to talk to each other.

Since they won't want to put every location onto the page (probably), yes: they will use AJAX to ask the server for a list of locations matching what the user types.

Quote

once a user selects  e.g.  Islington, London    .

does this then add that as a $variable to a select statement to the database to create a list of properties on the next page ? 

$location = islington

select * from table where $location 

Something like that.

Share this post


Link to post
Share on other sites
Posted (edited)

furlongs lol...  

'something like that'  

anyone care to look at rightmove and tell me what the hell is going on under the hood?  could be ' typeahead' j.s . with a json file of postcodes and counties,.Could be ajax calling the locations from the database...

just because i type ajax into google doessnt mean that is the correct way to do it...  sweet jesus mother of god....   its like getting blood from bent coppers round here, so it is 

 

 

 

 

Edited by glendango

Share this post


Link to post
Share on other sites

Furlongs are nice, round unit of measure (1 furlong = 10 cricket pitches)

I can't see Rightmove's code any better than you can.

Share this post


Link to post
Share on other sites

Any more cheek and i'll throw the book at you , so i will. 

Share this post


Link to post
Share on other sites

View the rightmove page with your browser's developer tool/network tab open and watch the ajax calls

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.