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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to