I want to implement Time/Distance^2
in solr. e.g.:
user locality is : BTM
Question1: posted 5hrs before. and distance from my locality is 2kms :5/4=1.25
Question2 posted 2hrs before. and distance from my locality is 4kms: 2/16=0.125
Question3 posted 4hrs before. and distance from my locality is 3kms : 4/9:0.44
Now when I fire the solr query, Results should come in the following order based on T/D^2
formula:
question1 then question3 and question1
You could use a function query. See FunctionQuery
You could order by the function. Use the functions div and pow.
sort=div(Time/pow(Distance,2)) asc
or
sort=div(Time/pow(Distance,2)) desc
You may add the function to the field list to debug the function:
fl=*,div(Time,pow(Distance,2))