Hi
i am trying to create Entity centric index by using painless script , i able to create entity index and upload data , but now i am trying to calculate time difference between two date .
my painless script looks like -
  //Copy doc source to local variable with shorter name
	def docSrc = ctx._source;
	if("create".equals(ctx.op)){
		//initialize entity state
		docSrc.Salesmans = [];
//		docSrc.profile = "newbie";
	}    
	
    // Convert seller array into map for ease of manipulation
    def SalesmanMap =[:];
    for (salesman in docSrc.Salesmans) {
      SalesmanMap[salesman.SalesmanCode]=salesman;
    }
    
    // Consolidate latest batch of events
    for (event in params.events) {
      def salesman =SalesmanMap[event.SalesmanCode];
      
        salesman=[
          "SalesmanCode": event.SalesmanCode,
		 "VisitStartTime": event.VisitStartDateTime,
		"VisitEndTime":event.VisitEndDateTime,
		"timespend":43
        ];
        SalesmanMap[salesman.SalesmanCode]=salesman;
	
    }
docSrc.Salesmans=SalesmanMap.values();
	
	docSrc.TimeinMarket = 100;
in the timespend column i need event.VisitStartDateTime - event.VisitEndDateTime into minute , but not able to get , any suggestion .
Thanks