Tracking products

Tracking products. Return the different positions of a product during the manufacturing pipeline.

T-Cypher query:

RANGE_SLICE [2019-01-01T08:00:00Z; 2019-01-01T09:00:00Z], [2019-01-01T09:30:00Z; 2019-01-01T10:00:00Z] ON R

MATCH (product) –[i:isIn]-> (m:machine)

RETURN m, i@T


Cypher query:

MATCH (product)-[i:`isIn`]->(m:`machine`)

WHERE (myFunctions.min([i.tEnd, 1546333200000]) – myFunctions.max([i.tStart, 1546329600000])) > 0

RETURN m, [i.tStart, i.tEnd] AS `i@T`

UNION

MATCH (product)-[i:`isIn`]->(m:`machine`)

WHERE (myFunctions.min([i.tEnd, 1546336800000]) – myFunctions.max([i.tStart, 1546335000000])) > 0

RETURN m, [i.tStart, i.tEnd] AS `i@T`


Interpretation:

The trim clause is used to prune the search space of the query to two time intervals. Having this, the same temporal query will be evaluated for each of the time intervals. The returned result is the union of the sub-results returned from the evaluation of the query with each of the time intervals. Note that, the translated query is composed of the union of two sub-queries such that each sub-query includes the constraints filtering time intervals that were not valid during a single time interval. In this example, the constraints are only added to the relationship variables.

To follow the different positions of a product we retrieve all the machines connected to the product with a temporary relationship i. Having this, the position refers to the machine and the time during which the product was recorded in each position refers to the time interval of the relationship variable i using the symbols @T.

Comments are closed.