Hi Christof,
Another Idea, more like a brute force approach: keep a "current_price"
field and update it daily with a cron job, either with the default price or
with the promotional price. This way you only need to change a very little
in your queries (sort by the new field) and just add a job to "fix the
prices" daily.
This should be simpler solution than changing your queries to
function_score.
Florentin
Am Dienstag, 27. Mai 2014 13:46:52 UTC+2 schrieb Christof Kaleschke:
>
> Hi,
>
> we use an index with products that have a default price. For certain
> periods of time a product can have a special price.
>
> The mapping looks like this at the moment:
>
> "mappings" : {
> "products" : {
> "properties" : {
> "defaultPrice" : { "type" : "float" },
> "actionPrice" : {
> "type" : "nested",
> "properties" : {
> "begin" : { "type" : "date", "format" :
> "YYYY-MM-dd" },
> "end" : { "type" : "date", "format" : "YYYY-MM-dd"
> },
> "price" : { "type" : "float" }
> }
> }, ...
>
> The user can sort for the price. So in the query we need the logic that if
> the current time is between a begin and end, then take this price else take
> the defaultPrice. Is that possible? How can I do that?
>
> Thanks
>
>
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/9dc4d381-151e-46f6-9f96-1372dee92e42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.