Hi colleagues. I want to ask:
I have a document
{
"product_id":1,
"price":10,
"action_prices":[
{
"from": 1385766000,
"to":1385938740.
"price": 9.5
},
{
"from": 1385938840,
"to":1385939740.
"price": 9.7
}
]
}
I have to select / filter / order current price. No problem to select,
using script_fields
"script_fields" : {
"current_price" : {
"script" : "p = _source.price;foreach (price :
_source.action_prices){if(price.from <= NOW && price.to >= NOW
){p=price.price}};return p;",
"params": {
"NOW":1385991511 //CURRENT_TIMESTAMP
}
}
}
Question is: how can I filter documents using current_price? something like
this:
"query":{
"filtered":{
"query":{
"match_all": {}
},
"filter":{
"numeric_range": {
"action_prices.price ": {
"gte":0,
"lte":10000
}
}
}
}
}
P.S. Maybe I can add additional array element to index for non existing
action prices? But how can I filter by this situation? I mean
"action_prices":[
{
"from": 1385766000,
"to":1385938740.
"price": 9.5
},
{
"from": 1385938840,
"to":1385939740.
"price": 9.7
},
{
"from": 0,
"to":9999999999.
"price": 10
}
]
Thank you so much.
--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7f00d550-919f-481f-bd9b-5d7eef057f64%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.