window_match

window_match(str fieldname, unsigned int dt0, unsigned int dt1) allows window matching between dates.

The function returns True if params[fieldname]is between doc[fieldname] - dt0 to doc[fieldname] - dt1

Input

  • fieldname (str) - the name of the field to match in query docmuent and database document. params[fieldname] and doc[fieldname] must be of type int

  • dt0 (unsigned int) - the left margin of the window. Must include units (s/m/h/d).

  • dt1 (unsigned int) - the right margin of the window. Must include units (s/m/h/d).

Output

  • (Boolean) - True if doc[fieldname] - dt0 < params[fieldname] < doc[fieldname] - dt1, and False otherwise.

Example:

if window_match(Arrival_times, “3d”,“1d"):
   pass

The window_match condition will return True if

doc[fieldname] - 3d< params[fieldname] < doc[fieldname] - 2d

For example, if params[fieldname]=1698225495, which is equivalent to GMT October 25, 2023 9:18:15 AM, and doc[fieldname]=1698311895, which is equivalent to GMT October 26, 2023 9:18:15 AM, then window_match will return false because params[fieldname] > params[fieldname] - 2d

Last updated