Time diffrence in painless script

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;

		//initialize entity state
		docSrc.Salesmans = [];
//		docSrc.profile = "newbie";
    // Convert seller array into map for ease of manipulation
    def SalesmanMap =[:];
    for (salesman in docSrc.Salesmans) {
    // Consolidate latest batch of events
    for (event in params.events) {
      def salesman =SalesmanMap[event.SalesmanCode];

          "SalesmanCode": event.SalesmanCode,
		 "VisitStartTime": event.VisitStartDateTime,
	docSrc.TimeinMarket = 100;

in the timespend column i need event.VisitStartDateTime - event.VisitEndDateTime into minute , but not able to get , any suggestion .

You will need to parse the dates to do date math on them. The java time api is available in painless. Also note that you probably want end date minus start date (otherwise you would have a negative time).


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