Querying the Graph

Overview

AgeDigitalTwins supports two query languages:

  1. Azure Digital Twins Query Language: Refer to the official documentation.
  2. Cypher: Built on Apache AGE, Cypher queries provide powerful graph querying capabilities.

The used query language is automatically detected based on the query syntax.

Cypher Query Language for Digital Twins

Basic Queries

  • Find all twins:
    MATCH (t:Twin) RETURN t;
    
  • Find relationships:
    MATCH (t:Twin)-[r]->(m:Model) RETURN t, r, m;
    

Using digitaltwins.is_of_model

  • Find twins of a specific model:
    MATCH (t:Twin) WHERE digitaltwins.is_of_model(t, 'dtmi:com:adt:dtsample:room;1') RETURN t;
    

ADT Query Functions and Cypher Equivalents

ADT Query FunctionCypher Equivalent
IS_OF_MODELdigitaltwins.is_of_model
STARTSWITHSTARTS WITH
ENDSWITHENDS WITH
CONTAINSCONTAINS
IS_NULLIS NULL
IS_DEFINEDIS NOT NULL

For more examples, refer to the AdtQueryToCypherTests.cs.