Link to home
Start Free TrialLog in
Avatar of yoshcomputers
yoshcomputers

asked on

Index Scoring algorithm

I have a search index that I can only return results based off one scoring function, but I need to consider two values.

I want to rank documents that have the closest distance to the searching lat/long and then within items that have the same distance, I want those items to be scored so that the items with the earliest UTC timestamp value rank highest.

So far independently, I use the following function to score closest items
-miles(query[lat],query[long],document[lat],document[long]

This puts items that have the largest distance with the largest negative number.  Items closer to 0 (ie the smallest distance will be closer to 0 and thus rank higher).  This is good.

But I am also storing the event date of the document as a UTC time stamp.  Thus documents that happen earlier will have a smaller UTC value than those that are happening later.

So I am needing help coming up with a function that will give highest weight to items that have the smallest distance but occur earliest.

For instance:
A is -.01 miles away with start date of July1,2012
B is -.1 miles away with start date of July1,2012
C is -.01 miles away with start date of Jan1,2012
D is -.1 miles away with start date of Jan1,2012
E is -.01 miles away with start date of Dec1,2012
F is -.1 miles away with start date of Dec1,2012

I would want the results to be in the following order
C
A
E
D
B
F

Last catch is all the results have to be negative numbers so that the highest ranking value is the value closest to 0.  The bigger the number the farther away from 0 the lower the ranking will be.

I have access to the following operators and functions:
Operators: +, -, *, /
Functions: Natural Logarithm, Power, Max, Min, Absolute, Square root
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yoshcomputers
yoshcomputers

ASKER

I actually had to tweak it just a bit because the inverse of the timestamp was too small of a number:

(-miles)-timestamp/10000000000

but since your solution was the inspiration you deserve the points.