algorithm - Smart sorting by function of geo and int -


i'm thinking ways solve following task.

we developing service (website) has objects. each object has geo field (lat , long). it's 200-300 cities objects can connected. amount of objects thousands , tens of thousands.

also each object has date of creation.

we need search objects sorting function of distance , freshness.

e.g. have 2 close cities , b. user city authorizes , should see objects city , then, on next pages, city b (because objects closer). but, if there object added year ago, , object b added today, b's object should displayed befare a's one.

so, peoeple city can create special field relevant index = 100*distance + age_in_days , sort field , data need.

the problem such relevant index not work other people other places.

in example used linear function it's example, need fit correct function.

the site work on our servers, can use database or other software (i supposed use mongodb)

i have following ideas

  1. recacl relevant index every day , keep object like

    {     fields : ...,     relindex : {         citya : 100,         cityb : 120     } } 

    and if user belongs citya sort relindex.citya

disadvantages:

  • recurrent update of object, dont think it's hude problem
  • huge mongo index. if have 300 cities each object have 300 indexed fields
  • hard add new cities.

  1. use 3d spatial index: (lat, long, freshness). dont know if database supports 3d geo-patial

  1. compact close objects in cluster , search in cluster not whole base. im not sure it's ok.

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -