To enable a user friendly query language, we provide one based on Cypher (https://neo4j.com/developer/cypher/). We use it only for search and not for creation.
We made some adaptations to fit to the Thing'in data model. Here we list the more outstanding rules of translation.
Be carrefull to use single quote
`
and not'
or you will have syntax error
You can use POST /avatars/find to make Cypher for Thing'in query, using the cypher
key instead of query
Ex:
{
"cypher":"MATCH ..."
}
In Cypher nodes have labels and can be filtered according to them. In Thing'in, two concepts can fit this requirements : classes and labels. Then in Cypher for Thing'in you can use both as labels.
Remember that, Cypher labels starting with
http://
orhttps://
are translated to classes.
TiQL
{
"$classes" : {"$contains" : "UNE_CLASSE"}
}
Cypher for Thing'in
MATCH (:`UNE_CLASSE`) RETURN *
TiQL
{
"$label" : {"$contains" : "UN_LABEL"}
}
Cypher for Thing'in
MATCH (:`UN_LABEL`) RETURN *
TiQL
{
"$classes" : {"$contains" : "UNE_CLASSE"},
"$label" : {"$contains" : "UN_LABEL"}
}
Cypher for Thing'in
MATCH (:`UNE_CLASSE`:`UN_LABEL`) RETURN *
In TiQL, some keywords are reserved to point out the avatar properties : $classes
, $inheritance
, $label
, $iri
, $lastUpdated
, $domain
, $uuid
, $cluster
, $acl
, $group
, $visibility
, $static
.
In Cypher for Thing'in, these properties could be accessed through dedicated node properties :
$classes
→ classes
$inheritance
at true
with $classes
constraint → inherited_classes
$label
→ label
$iri
→ iri
$lastUpdated
→ lastUpdated
$domain
→ domain
$uuid
→ uuid
$cluster
→ cluster
$acl
→ acl
$group
→ group
$visibility
→ visibility
$static
→ static
TiQL
{
"$iri" : "IRI",
}
Cypher for Thing'in
MATCH ({iri:`IRI`}) RETURN *
TiQL
{
"$label" : {"$contains" : "UN_LABEL"},
"$domain" : "MON_DOMAIN",
"$visibility" : {"$geq" : 0}
}
Cypher for Thing'in
MATCH (a:`UN_LABEL` {domain:`MON_DOMAIN`}) WHERE a.visibility >= 0 RETURN *
Here conditions should be express in the WHERE clause
ROOM
) that are in (ontology concept isIn
) a building having an iri B_IRI
TiQL
{
"query" : [
{
"$alias" : "b",
"$iri" : "B_IRI",
},
{
"$alias" : "r",
"$classes" : {"$contains" : "ROOM"},
"->isIn" : "b"
}
],
"return" : "r"
Cypher for Thing'in
MATCH ({iri:`B_IRI`})-[:isIn]->(r:ROOM) RETURN r
TiQL
{
"query" : [
{
"$alias" : "d",
"$iri" : "D_IRI",
},
{
"$alias" : "s",
"$classes" : {"$contains" : "SENSOR"},
"$relationships":[
{
"START_TIME": {"$geq": 8},
"END_TIME": {"$lte": 12},
"$avatar":"d",
"$label":"CONNECTED_TO",
"$direction":"OUT"}
]
}
],
"return" : "s"
Cypher for Thing'in
MATCH (s:SENSOR)-[c:CONNECTED_TO]->({iri:`D_IRI`}) WHERE c.START_TIME >= 0 AND c.END_TIME <= 12 RETURN s