I created a type called test , which consists of a nested price field .
Each document may consist of several prices, and each price consists of a price and a date :
...
"prices":[{
"date" : "2017-02-08T16:04:20.424Z",
"price" : 120
},
{
"date" : "2017-02-08T17:35:01.424Z",
"price" : 70
}]
...
I am trying to create a search query that first aggregates the prices of each document to the minimum price , and then dials all the minimum values returned from the aggregation using the linear decay function
Currently, I have an aggregation request for all documents:
{
"query": {
"match_all": {}
},
"aggs" : {
"prices" : {
"nested" : {
"path" : "prices"
},
"aggs" : {
"min_price" : { "min" : { "field" : "prices.price" } }
}
}
}
}
This returns the minimum price in the test .
, :
{
"query": {
"nested": {
"path": "prices",
"query": {
"function_score": {
"functions": [
{
"linear": {
"prices.price": {
"origin": "50",
"offset": "50",
"scale": "20"
}
}
}
]
}
}
}
}
}
.
, , , .
?