Hi, I have never tried it, so take my advice with a grain of salt. Your problem looks like a good usage of function scoring:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_using_function_score Functions used in scoring can have filters. So theoretically you should obtain what you want a first function with a date range filter and the value of the time limited price and a second function, without filters which has the value of the default price. You should probably use "score_mode": "first" and "boos_mode": "replace" so that you only sort by these functions. I hope this idea helps a little. Kind regards, 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/219804cb-6cdb-41cc-bbb8-ddd61eda4076%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
