Hi,

There is no way to do it on the Elasticsearch side for the moment. It can
only be done on client side.


On Wed, May 7, 2014 at 1:37 PM, Alex Mathew
<[email protected]>wrote:

> How to write an ES query to find the difference between max and min value
> of a field?
>
> I am a newbee in elastic search, In my case I feed lot of events along
> with session_id and time in to elastic search. My event structure is
>
> Event_name string
> Client_id  string
> App_id     string
> Session_id string
> User_id    string
> Ip_address string
> Latitude   int64
> Longitude  int64
> Event_time time.Time
>
>
> I want to find the life time of a session_id based the feeded events. For 
> that I can retrive the maximum Event_time and minimum Event_time for a 
> particular session_id by the following ES query.
>
> {
>   "size": 0,
>   "query": {
>      "match": {
>         "Session_id": "dummySessionId"
>      }
>   },
>    "aggs": {
>       "max_time": {
>          "max": {
>            "field": "Time"
>           }
>        },
>        "min_time":{
>           "min": {
>             "field": "Time"
>           }
>        }
>     }
>   }
>
>
> But what I exact want is (max_time - min_time) How to write the ES query for 
> the same????
>
>  --
> 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/1e937884-4052-4a5a-91db-bc1449c43efe%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/1e937884-4052-4a5a-91db-bc1449c43efe%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adrien Grand

-- 
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/CAL6Z4j5%2BqaQzU6UAyD5-B%3Dv8R4yZQ%2B2wAUvH-%3D_mSrWRHk_erA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to