# 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.

Operators: +, -, *, /
Functions: Natural Logarithm, Power, Max, Min, Absolute, Square root
ozo

membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yoshcomputers