Can Elasticsearch produce temporary field like Mysql?


(windcandle) #1

In Mysql sql,we can "select id,name,min(price) as min_price from table group by id".This min_price is a temporary field.In Elasticsearch ,How can I do?
eg:
{
"id":1,
"name":"windcandle",
"prices":[
{
"date":"2016-12-29",
"price": "20.00"
},
{
"date":"2016-12-30",
"price": "21.00"
},
{
"date":"2016-12-31",
"price": "20.00"
},
.....
}.

}
I want to get id ,name ,min_price,How Can I do?


(Mark Walkom) #2

There is no such concept in ES, you can only just get the min value - https://www.elastic.co/guide/en/elasticsearch/reference/5.1/search-aggregations-metrics-min-aggregation.html


(windcandle) #3

Thanks for you .But this result is minimum of all documents .I want to get the minimum price of each document.
each document has many price.
I try this .

{
"query": {
"match_all": {}
},
"script_fields": {
"min_price": {
"script": {
"inline": "_source.roomType.pricedates.price"
}
}
}
}
but can not!


(system) #4

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