Search by multiplier hops

Hi,

First time poster! Please excuse my newbie question, I've spent some time googling but could not come up with much. My question is:

If I wanted to index a service provided by the minute (by different providers):
For each provider I have information regarding base price for 30 minutes and additional price per minute. I would like to eventually query by price and amount of minutes required for service.

What would be the best way to index this? And then what kind of query would I need to do to fetch that information (calculating price by base price + additional minutes)?

Any information / documentation regarding such problem would be greatly appreciated.

Thanks in advanced,
Ben.

1 Like

Maybe the first question was not clear, so I'll provide an example:
given service providers:
{
id: "a",
base_price_for_thirty_minutes: 20,
additional_price_per_minute: 1
},
{
id: "b",
base_price_for_thirty_minutes: 20,
additional_price_per_minute: 10
}
{
id: "c",
base_price_for_thirty_minutes: 20,
additional_price_per_minute: 5
}

I want to query:
budget: 25
time: 35

the result would be: "a", because "a" is the only one who would sell 35 minutes worth of service for the given budget.

budget >= (base_price_for_thirty_minutes + ((time - 30) * additional_price_per_minute)

1 Like

Since you have a nice, compact formula to represent this logic, I think the best approach is to index as you have (field for the base price, and another field for the additional per-minute price). Then use a script_query to filter the documents.

You could make that a filter only (in a boolean query, or constant score) and rank the documents with other information. Or you could use the script to also rank, e.g. based on how much money is left over in the budget or something.

1 Like

Thank you Zachary!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.