Cypher reference¶
ZypherDB speaks openCypher, the query language of graph databases. It adds a few extensions and leaves out a few features; both are listed below. This page is the complete reference, and the tutorial introduces each feature by example.
Lexical structure¶
Keywords are case-insensitive:
MATCHandmatchare the same keyword. Identifiers are case-sensitive; that covers variables, labels, relationship types and property names. Write an identifier that has spaces or symbols between backticks:(`my node`:`Floor 3`). A label, relationship type, property name or index name cannot be empty, be longer than 1024 bytes or contain the character U+0000 (writes and schema commands refuse it; this also covers keys of a map inSET n += $map).Strings use single or double quotes (
'Ana',"Ana"), with backslash escapes:\',\",\\,\n,\t,\r,\b,\f, and\uXXXXor\UXXXXXXXXfor a code point. A\uor\Uwithout its hexadecimal digits, or not a code point, is a syntax error; any other backslash stays as it is ('\q'is the two characters\q).Numbers:
integers in decimal, hexadecimal (
0x1F) or octal (0o17);floats (
1.5,.5,1e3,2.5e-3).
Comments:
// to the end of the lineand/* … */.Parameters:
$nameis a value passed with the query (in Python,db.query(text, name=value)). A parameter is always a value; it cannot stand for a label, a type or a property name. Every parameter the query names must be passed (asnullif need be): a missing one fails before the query runs, as in Neo4j, even if no row would reach it.EXPLAINplans without running, so it needs none.
Clauses¶
A query is a pipeline of clauses. Each clause receives the rows of the clause before it and passes its own rows on; the first clause receives one empty row.
Clause |
What it does |
|---|---|
|
extends each row with every match of the patterns that passes the condition; comma-separated patterns are matched together |
|
like |
|
for each row, keeps the |
|
produces one row per element of the list (no row for an empty list or |
|
one row per record of a CSV file: a list of strings, or with headers a map from each header to its field; an empty field is |
|
runs a procedure for each row; each row it returns extends the row with the yielded columns |
|
runs the updating clauses ( |
|
runs the subquery for each row, in turn (a row sees what the subquery wrote for the rows before it). It sees the row’s variables only if it imports them: a first |
|
projects the rows like |
|
creates the nodes and relationships of the pattern; a node already bound is reused as it is, and |
|
matches the whole pattern, and each match becomes a row (with |
|
|
|
removes a property ( |
|
deletes nodes, relationships and paths, given by any expression ( |
|
produces the result of the query |
|
combines the rows of both parts ( |
Clauses chain in any number and order, with these rules:
after a writing clause, a
WITHmust come before reading again (MATCH,UNWIND,CALL);RETURNcomes last;a query ends with
RETURNor with a writing clause;a
CALLwithoutYIELD(or withYIELD *) ends the query, and its rows are the result. So does aCALL … YIELDthat is the whole query. Inside a longer query, aCALLnames the columns it uses withYIELD.
RETURN *andWITH *project every variable in scope, in name order; more items may follow (RETURN *, n.name AS name).The
WHEREof aWITHfilters the projected rows beforeDISTINCT,ORDER BY,SKIPandLIMITapply. When theWITHdoes not aggregate, itsWHEREcan also use the variables from before theWITH.ORDER BY x [ASC | ASCENDING | DESC | DESCENDING], …sorts the rows, ascending by default. Ascending order putsnulls last.SKIPandLIMITtake an integer expression or a parameter.ORDER BYuses the projected names, and, when the projection neither aggregates nor isDISTINCT, the variables from before it too. A part of anORDER BYexpression that repeats a projected expression reads its column:WITH a.name AS name, count(*) AS c ORDER BY a.namesorts byname.A query is checked before it runs. It fails with an error, and changes nothing, when it:
uses a variable that is not defined;
CREATEs orMERGEs a bound node alone or with new labels or properties, or a bound relationship;MERGEs a relationship without exactly one type;aggregates in a
WHEREor in a procedure’s arguments;names two columns of one projection alike, or two
YIELDcolumns alike;after
DISTINCT, sorts by something that is not projected.
A whole query is one transaction,
UNIONincluded: either all of its writes are kept or none are.
Patterns¶
(n:Label1:Label2 {prop: value, …}) a node: variable, labels, property equalities
-[r:TYPE {prop: value, …}]-> <-[r:TYPE]- -[r]- a relationship: outgoing, incoming, either way
--> <-- -- anonymous relationships
-[:A|B]-> one of several types
-[*]-> -[*2]-> -[*1..3]-> -[*..3]-> -[*0..]-> variable length: 1+, exactly 2, 1 to 3, up to 3, 0+
path = (a)-[:TYPE*]->(b) a path variable
path = shortestPath((a)-[:TYPE*]-(b)) only a shortest path between a and b
path = allShortestPaths((a)-[*..10]->(b)) every shortest path between them
Every part is optional:
()is a node with no variable, label or properties, and a relationship without a type matches any type.A node with several labels must have all of them.
{prop: value}is an equality test on the property. When the value is a constant or a parameter and an index covers the node’s label and the property (see schema commands), ZypherDB answers it with an index seek.A variable-length relationship binds its variable to the list of the path’s relationships, in pattern order.
*0..includes the start node itself.Within one
MATCH, each relationship is used at most once, so a path never goes back over the same relationship.Each relationship has an id of its own (
id(r)), so two nodes may be joined by several relationships of one type (parallel ones), each matched, changed and deleted on its own.shortestPathandallShortestPathstake a pattern of one variable-length relationship (*,*..n, or*0..to include the start). For each pair of end nodes they keep one shortest path, or every path of the shortest length; an unbound end gets a path to each node reached. When theWHEREreads the path (its variable, or the relationship list), the result is the shortest path theWHEREkeeps: paths are then tried by increasing length, which explores every path up to that length (bound it with*..non large graphs). Otherwise a breadth-first search finds them, in time proportional to the part of the graph it reaches.
Expressions¶
Values and access¶
The literals are:
numbers;
strings;
true,falseandnull;lists, such as
[1, 'a', [2]];maps, such as
{name: 'Ana', floors: [1, 2]}.
Form |
Meaning |
|---|---|
|
a property of a node or relationship, or an entry of a map; |
|
a list element (a negative index counts from the end, an index out of range gives |
|
a list slice; either end may be left out, and negative values count from the end; a |
|
true if the node has every label ( |
|
a map projection: the map built from the selectors, in order — a property ( |
Operators, by precedence (tightest first)¶
Operators |
Meaning |
|---|---|
|
access (see above) |
unary |
sign |
|
power; the result is always a float ( |
|
arithmetic. Two integers give an integer: |
|
arithmetic. |
|
tests; |
|
true if the whole string matches the regular expression (Java’s syntax, as in Neo4j); |
|
comparison; comparisons chain, so |
|
|
|
|
|
|
|
Equality:
numbers compare by value (
1 = 1.0);NaNequals nothing;lists and maps compare element by element;
values of different types are never equal.
Ordering (
<and the others) is defined between:numbers;
strings, by code point;
booleans (
false < true);lists, element by element;
temporal values of the same type. Date-times and times compare by the instant they denote.
Ordering any other pair of values gives
null.nullmeans unknown. An operator with anulloperand givesnull, sonull = nullisnull. The exceptions areIS NULL, andAND/ORwhen the other operand decides the result (false AND nullisfalse).WHEREkeeps a row only when its condition istrue.
Conditionals, comprehensions and subqueries¶
Form |
Meaning |
|---|---|
|
the value of the first branch whose condition is true ( |
|
the value of the first branch whose value equals |
|
list comprehension ( |
|
quantifiers, three-valued when |
|
pattern comprehension: |
|
pattern predicate: true if the pattern has a match; it cannot bind new variables |
|
true if the pattern has a match, or the subquery a row. The subquery is any query that only reads ( |
|
the number of matches of the pattern, or of rows of the subquery (the same forms as |
|
a parameter |
Functions¶
Function names are case-insensitive. A function returns null when given a null argument,
unless noted otherwise. Calling an unknown function, or passing the wrong number of arguments, fails
before the query runs.
Group |
Functions |
|---|---|
Lists |
|
Strings |
|
Conversion |
|
Numbers |
|
Null |
|
Graph |
|
Paths |
|
Vectors |
|
Temporal |
see Temporal values |
Nodes and relationships have ids of their own, each counted from 0: a node and a relationship may
have the same id().
Aggregation¶
The aggregates are:
count(x)andcount(*);sum(x), an integer unless a float is summed;avg(x),min(x),max(x);collect(x), which builds a list;stDev(x)andstDevP(x), the sample and population standard deviation;percentileDisc(x, p)andpercentileCont(x, p), the percentilep(between 0 and 1) of the numbers: the nearest value, or one interpolated between the two nearest.
Each aggregate accepts DISTINCT to use each value only once: count(DISTINCT x).
In
RETURNorWITH, every item that has no aggregate is a grouping key, and the result has one row per distinct combination of keys. Without keys, all rows form one group. An empty input still gives that one row:countis 0,sumis 0, and the other aggregates givenullor[].Aggregates skip
nullvalues;count(*)counts rows.An aggregate can appear inside an expression (
count(*) + 1,sum(x) * 100 / count(*)). Outside its aggregates, such an expression may only use constants, parameters, and grouping keys that are themselves projected.ORDER BYmay use the names the projection defines and the aggregates it computes.
Values and properties¶
The value types are:
null, booleans, integers (64-bit), floats (64-bit) and strings (UTF-8);lists and maps;
nodes, relationships and paths;
the six temporal types.
A property of a node or relationship may hold:
a boolean, number, string or temporal value;
a list whose elements share one of those types (integers and floats count as one type);
a map.
Setting a property to null removes it.
Documents (maps stored as properties) are a ZypherDB extension, since openCypher does not store
maps. A document may nest maps and lists of any values, nulls included, but it cannot contain
nodes, relationships or paths.
Read its fields with the usual operators:
n.doc.address.city.An index on a document property indexes the whole document, for equality. A field inside a document can have an index of its own (
CREATE INDEX FOR (p:Person) ON (p.emergency.relation), see schema commands); without one, a condition on the field is checked by reading each candidate.
tests/tck/deviations.txt lists the TCK scenarios where this extension gives a different answer
from standard openCypher.
Temporal values¶
Type |
Text form |
Constructor |
|---|---|---|
date |
|
|
local time |
|
|
time |
|
|
local date-time |
|
|
date-time |
|
|
duration |
|
|
Constructors take one of:
an ISO 8601 string (dates also as
2015-W30-2,2015-202or20150721);a map of fields (below);
another temporal value, which is converted;
no argument, which gives the current time. That time is the same throughout one statement:
date.statement()anddate.transaction()(and the same for the other types) also give it;date.realtime()and the like read the clock each time.
The maps a constructor accepts:
dates:
{year, month, day},{year, week, dayOfWeek},{year, ordinalDay}, or{year, quarter, dayOfQuarter}.{date: d, …}changes some fields of a base dated.times:
{hour, minute, second, millisecond, microsecond, nanosecond}.{time: t, …}changes some fields of a base timet.zones:
timezone: '+01:00'ortimezone: 'Europe/Madrid'. On a value that already has a zone it converts, giving the same instant elsewhere; on a value without a zone it places the value in that zone.durations: any of
years,quarters,months,weeks,days,hours,minutes,seconds,milliseconds,microsecondsandnanoseconds. Fractional values are allowed ({days: 1.5}).
Components are read like properties (d.year):
dates and date-times:
year,quarter,month,week,weekYear,day,ordinalDay,dayOfWeek(1 = Monday),weekDay,dayOfQuarter;times and date-times:
hour,minute,second,millisecond,microsecond,nanosecond;values with a zone:
timezone,offset,offsetMinutes,offsetSeconds;date-times also:
epochSeconds,epochMillis;durations:
years,quarters,months,weeks,days,hours,minutes,seconds,milliseconds,microseconds,nanoseconds. The remainders arequartersOfYear,monthsOfQuarter,monthsOfYear,daysOfWeek,minutesOfHour,secondsOfMinute,millisecondsOfSecond,microsecondsOfSecond,nanosecondsOfSecond.
Functions:
duration.between(a, b)gives the months, then the days, then the time that remains.duration.inMonths,duration.inDaysandduration.inSecondsgive the difference in a single unit.date.truncate(unit, value[, map])truncates a value, and the other temporal types have the same function. The units aremillennium,century,decade,year,weekYear,quarter,month,week,day,hour,minute,second,millisecond,microsecond.datetime.fromepoch(seconds, nanoseconds)anddatetime.fromepochmillis(milliseconds)build a date-time from the Unix epoch.
Arithmetic and comparison:
A temporal value plus or minus a duration: the months and days move the calendar, and the time part moves the clock. For example,
date('2025-01-31') + duration('P1M')is2025-02-28.Durations add and subtract, and multiply or divide by numbers.
Values of the same type compare in time. Durations compare only for equality.
Precision is the nanosecond, and years range over ±999,999,999. The default time zone is UTC. Named
zones (Europe/Madrid, matched exactly, case included) come from the IANA time zone database
embedded in ZypherDB (vendor/tzdata), not the system’s, so a zone’s history is the same on every
machine.
Procedures¶
Procedure |
Yields |
What it returns |
|---|---|---|
|
|
the labels some node carries |
|
|
the types some relationship has |
|
|
the nodes of a full-text index that match |
|
|
the same, for an index of relationships |
|
|
the full-text analyzers |
|
|
the |
|
|
the same, for an index of relationships |
|
nothing |
waits until no vector index is being populated |
Procedure names are case-sensitive, as in Neo4j. The options of a full-text query are a map with
skip and limit, non-negative integers.
A CALL that is the whole query may leave out the parentheses: CALL db.labels. A procedure that
takes arguments then takes each one from the query parameter of the same name.
Schema commands¶
As in Neo4j, a property is indexed only when an index is created for it: CREATE INDEX for
equality and range lookups, CREATE FULLTEXT INDEX for words, CREATE VECTOR INDEX for
nearest neighbours. Constraints keep values unique.
Each schema command is a statement of its own:
CREATE FULLTEXT INDEX name [IF NOT EXISTS]
FOR (n:Label1|Label2) ON EACH [n.property1, n.property2]
[OPTIONS {indexConfig: {`fulltext.analyzer`: 'spanish'}}]
CREATE FULLTEXT INDEX name [IF NOT EXISTS]
FOR ()-[r:TYPE1|TYPE2]-() ON EACH [r.property]
[OPTIONS {...}]
CREATE [RANGE | TEXT] INDEX [name] [IF NOT EXISTS]
FOR (n:Label) ON (n.property) -- or FOR ()-[r:TYPE]-() ON (r.property)
-- or a document field: ON (n.property.field)
CREATE VECTOR INDEX [name] [IF NOT EXISTS]
FOR (n:Label) ON n.property -- or FOR ()-[r:TYPE]-() ON r.property
OPTIONS {indexConfig: {`vector.dimensions`: 384, `vector.similarity_function`: 'cosine',
`vector.hnsw.ef_search`: 100}}
CREATE CONSTRAINT [name] [IF NOT EXISTS]
FOR (n:Label) REQUIRE n.property IS UNIQUE -- or REQUIRE (n.a, n.b) IS UNIQUE
DROP INDEX name [IF EXISTS]
DROP CONSTRAINT name [IF EXISTS]
SHOW [FULLTEXT | RANGE | VECTOR] INDEXES
SHOW CONSTRAINTS
Indexes and constraints share one namespace of names. Without a name,
CREATE INDEXandCREATE CONSTRAINTmake one of what they are on (index_Card_number,constraint_Door_building_number).IF NOT EXISTSmakesCREATEdo nothing when the name is taken. Otherwise a taken name is an error.IF EXISTSdoes the same forDROP.DROP INDEXof a constraint (orDROP CONSTRAINTof an index) is an error.A full-text node index covers the nodes with any of the labels; a relationship index covers the relationships of any of the types.
CREATEindexes what the graph holds already. From then on, every change keeps the index current, in the transaction that makes it.fulltext.eventually_consistentis accepted inindexConfigand has no effect, since ZypherDB’s indexes are always current.A
RANGEindex (aTEXTindex, or one with no kind, is the same) is on one label and one property, or one relationship type and one property. Queries use it to find nodes by an equality on the property ({id: $id},WHERE n.id = $id), or by a range of numbers, strings, dates, times or date-times (WHERE n.age > 60), when the pattern’s node has the label; a node without a label is found by reading every node, as in Neo4j. A relationship’s index serves equalities on a relationship with that single type. An index on several properties is refused: create one per property. ItsOPTIONSare ignored.Document fields (a ZypherDB extension):
ON (n.emergency.relation)indexes the fieldrelationof the map inn.emergency, at any depth. A node whose property is not a map, or has no such field, is not in the index.WHERE n.emergency.relation = $rand ranges on the field use it.A uniqueness constraint’s own index also serves lookups on the constraint’s first property.
Long values are indexed by their first 512 bytes and checked whole, so any value can be indexed. For the size limits on names and values, see storage: limits.
Uniqueness constraints are on one node label, and one property or several together. A write that would give a node of that label the same values as another (by
CREATE,SET,MERGE, a new label, or the Python and C write functions) fails with a constraint violation (ConstraintViolationErrorin Python, error code 10), and its query writes nothing. A node without one of the properties is not concerned. The check is made at each write, so swapping two nodes’ values in one query fails.CREATE CONSTRAINTfails if the graph already has duplicates. Neo4j 4’sCREATE CONSTRAINT ON (n:Label) ASSERT n.p IS UNIQUEis accepted too. Other constraints (IS NOT NULL,IS NODE KEY, on relationships) are not supported.SHOW INDEXESreturns one row per index:name,type(FULLTEXT,RANGEorVECTOR; aTEXTindex is listed asRANGE, since it is one),entityType(NODEorRELATIONSHIP),labelsOrTypes,properties,owningConstraint,options. As in Neo4j 5, a uniqueness constraint’s own index is listed: aRANGEindex named as the constraint, with the constraint’s name inowningConstraint(null for the others), on the constraint’s first property (the one its keys hold);DROP INDEXrefuses it,DROP CONSTRAINTdrops both.SHOW VECTOR INDEXESadds three columns:state(POPULATING,ONLINEorFAILED),populationPercent(100 once online) andfailureMessage(null but for a failed index).SHOW CONSTRAINTSreturnsname,type(UNIQUENESS),entityType,labelsOrTypes,properties,ownedIndex.
Full-text search¶
A full-text index keeps the words of a node’s or relationship’s text properties. A property is indexed when it holds a string or a list of strings; other values are skipped.
Analyzers decide what the words are:
Analyzer |
Words |
|---|---|
|
split at anything not a letter, digit or mark; case-folded; accents and compatibility forms removed ( |
|
as |
|
as |
An apostrophe between letters stays inside a word (
O'Neill).The stemmers are Snowball’s: Porter2 for English, and Snowball’s Spanish algorithm.
A query is analyzed with its index’s analyzer.
Query syntax is the part of Lucene’s that Neo4j accepts:
Query |
Matches |
|---|---|
|
either word: clauses are optional by default |
|
the phrase, its words in a row in one property (a stop word in it leaves its gap) |
|
words that start with |
|
words up to 2 (or 1) edits away; compared stem to stem in a language index |
|
|
|
the same with words |
|
in the property |
|
a group |
|
the clause’s score doubled |
|
a special character as itself |
Clauses combine as in Lucene’s boolean queries. When the query has required clauses, a match has all of them, and the optional ones only add to its score. Otherwise a match has at least one optional clause. An excluded clause removes what it matches.
A word the analyzer splits in two (
nivel-3) is a phrase.?wildcards and wildcards inside a word are not supported. A query that does not parse fails with a message saying why.
Scores are BM25, with Lucene’s parameters (k1 = 1.2, b = 0.75):
a word counts more the rarer it is in the index, and the more often it occurs in the entity;
a short entity scores higher than a long one with the same occurrences;
a phrase scores as a word whose idf is the sum of its words’;
a prefix or fuzzy clause scores an entity by its best expansion, and a fuzzy one loses a share for each edit.
Results come best first.
Vector search¶
A vector index finds the nodes (or relationships) whose vector is closest to a given one: the embeddings of texts or images, compared by meaning. It is on one label (or relationship type) and one property, which holds a list of numbers:
CREATE VECTOR INDEX documents FOR (d:Document) ON d.embedding
OPTIONS {indexConfig: {`vector.dimensions`: 384, `vector.similarity_function`: 'cosine'}}
CALL db.index.vector.queryNodes('documents', 10, $question_embedding) YIELD node, score
RETURN node.title, score
Or, inside a query, with the SEARCH clause, which keeps the closest among the entities that
match a pattern and any condition:
MATCH (a:Author {name: $author})-[:WROTE]->(d:Document)
WHERE d.year >= 2020
SEARCH d IN (VECTOR INDEX documents FOR $question_embedding WHERE d.language = 'es' LIMIT 10)
SCORE AS score
RETURN d.title, score
vector.dimensions(1 to 4096) is required: how many numbers each vector has.vector.similarity_functionis'cosine'(the default) or'euclidean', in any case.vector.hnsw.ef_search(at least 1, 100 by default) is how many candidates a search looks at: more finds more of the true nearest, and costs more.A wrong vector is an error, not a skip. A write that would give an indexed node (one with the label) or relationship (of the type) something else in the property fails with a constraint violation (
ConstraintViolationErrorin Python, error code 10) and writes nothing: a value that is not a list of numbers, a list of another length, NaN or infinity, or all zeros under cosine (which has no direction). Neo4j leaves such entities out of the index instead, so that a change of embedding model shows up only as missing results; here it shows up at the first write. An entity without the property is simply not in the index.Populated in the background.
CREATE VECTOR INDEXreturns at once, having indexed what it could in about 20 ms (on a small graph, all of it); the rest is indexed by a thread of the open database, in batches of about 20 ms that writes run between. Writes keep the index current meanwhile. Until it is done,SHOW VECTOR INDEXESshows itPOPULATINGwith itspopulationPercent, and querying it is an error that says how far it got (error code 15,IndexPopulatingErrorin Python): retry later, or wait first.CALL db.awaitIndexes()waits until no vector index is populating, for at most 300 seconds (CALL db.awaitIndexes(60): 60); still populating then, it is the same error. It is the whole query, and not in a write transaction, since population needs the writer; on a replica it waits for the replica’s own indexes. Closed (or killed) before the end, the database goes on from there when it is opened again; population only moves while some process has the database open. If population meets a value that is not a vector the index takes, the index isFAILED:failureMessagenames the entity and what is wrong, writes no longer keep or check it, and querying it is an error. Correct the data, thenDROP INDEXand create it again;db.awaitIndexes()meeting a failed index is that error too. A replica populates its own copy of each index the same way, so it can beONLINEon the master and stillPOPULATINGon a replica.Rebuilt in the background. Removed entities stay in the graph as dead ends until they outnumber the live ones; the index is then rebuilt without them by the same thread, in batches, while queries keep using it as it was and it stays
ONLINE.DROP INDEXreturns at once too: the index’s storage is freed by that thread afterwards.The index keeps each vector as 32-bit floats (normalized under cosine); the property keeps the numbers as they were written.
Scores are Neo4j’s, between 0 and 1, higher is closer: cosine
(1 + cos(a, b)) / 2, euclidean1 / (1 + d²), wheredis the distance. Results come best first; equal scores by id.The search is approximate (an HNSW graph, as in Neo4j, Memgraph and FalkorDB): it looks at
max(k, ef)candidates,efbeing the index’svector.hnsw.ef_search, and finds nearly all of the trueknearest. The index follows every write in the transaction that makes it, as the other indexes do. Replicas keep their own: each moves an entity in its indexes as it applies the write that changed it.SEARCHfollows aMATCHorOPTIONAL MATCH(and itsWHERE). Its variable is a node or relationship that thisMATCHbinds, of the index’s label or type; for each row of the clauses before theMATCH, it keeps thekentities closest to the vector among those the pattern, theMATCH’sWHEREand theWHEREinsideSEARCHgive, best first, and every row of theMATCHwith one of them goes on. Sokcome out whenever at leastkmatch: the condition chooses among the candidates, it does not remove results after the search. Any condition works, on any variable in scope.SCORE AS sbinds the score. AWHEREafterSCORE ASfilters the rows after the search (it can use the score), so fewer thankmay be left. WithOPTIONAL MATCH, a row that keeps no entity goes on once, with nulls.The vector,
LIMITandOPTIONSare evaluated for each row, from the variables before theMATCH(or parameters). The vector is checked like a written one;nullis an error.OPTIONS {ef: 400}overrides the index’svector.hnsw.ef_searchfor this search.When few entities match (up to about
10 × ef, more on a large index),SEARCHmeasures each one: the answer is exact. When many match, it searches the HNSW graph, checking each entity it meets, and if that leaves fewer thankit measures all those that match.PROFILEsays how many rows took each way. Deciding means listing the matches up to that bound, so a condition no index answers reads entities of the label until it reaches it.Neo4j’s
SEARCHapplies the pattern and theMATCH’sWHEREafter the search, so it may return fewer thank, and its innerWHEREonly takes properties named when the index was created. A query written for Neo4j returns here the same rows plus those missing up tok.vector.similarity.cosine(a, b)andvector.similarity.euclidean(a, b)score two lists of numbers of the same length the same way, with no index. They returnnullif either isnull, or under cosine if one is all zeros; lists of other lengths, empty lists, or elements that are not finite numbers are an error.
EXPLAIN and PROFILE¶
EXPLAIN query returns the plan of the query without running it; PROFILE query runs the query
(its writes commit, as they would without PROFILE) and returns the plan with what each operator
did. Both take a query or a UNION, not a schema command. The result is one row per operator:
Column |
What it holds |
|---|---|
|
how deep the operator is: the chain an operator runs (an |
|
its name (below) |
|
what it works on, as Cypher: a pattern, a predicate, a projection |
|
how many rows it makes per run of its chain: a guess from the label and relationship-type counts, |
|
|
|
|
The first row is the result; each operator gets its rows from the one below it, down to where
they start. A chain an operator runs follows it, one level deeper; a pattern or subquery inside an
expression follows the operator that evaluates it, under a row naming it (Exists, Count,
PatternPredicate, PatternComprehension). On a graph with an index on :Person(id), where a
person is in five groups on average (and g has no label to count by):
MATCH (p:Person {id: $id})-[:MEMBER_OF]->(g)<-[:MEMBER_OF]-(q) RETURN count(DISTINCT q)
depth operator details estimated_rows
0 Return count(DISTINCT q) 1
0 Aggregation count(DISTINCT q) 1
0 Expand(All) (g)<-[:MEMBER_OF]-(q) null
0 Expand(All) (p:Person {id: $id})-[:MEMBER_OF]->(g) 5
0 NodeIndexSeek (p:Person {id: $id}) 1
Operator |
What it does |
|---|---|
|
finds a pattern’s first node by an equality on an indexed property ( |
|
finds it by a range of an indexed number or date property ( |
|
counts the nodes in a range of an indexed property from the index alone ( |
|
reads every node with the label, or every node |
|
finds a single relationship’s ends by an equality on its indexed property |
|
a node bound before the pattern: checks its labels and properties |
|
follows a relationship to each neighbour, or to a node bound already |
|
follows a variable-length relationship ( |
|
|
|
binds a path variable ( |
|
keeps the rows its predicate holds for (a |
|
|
|
|
|
|
|
a |
|
a |
|
|
|
|
|
the query’s result; alone when the |
|
the writing clauses |
|
in a query that writes: every row goes through the clause before it before any goes on |
|
the end of a query without |
|
the parts of a |
Not supported¶
ZypherDB does not implement these parts of openCypher (and of common Neo4j extensions):
procedures other than those listed;
CALL { … } IN TRANSACTIONS, andUNIONinsideCALL { … };LOAD CSVfrom URLs other thanfile:in the import directory;constraints other than uniqueness on nodes (
IS NOT NULL,IS NODE KEY, relationship constraints);TEXT,POINTandLOOKUPindexes (CREATE INDEXmakes a range index,CREATE FULLTEXT INDEXa full-text one);SEARCHover a full-text index (usedb.index.fulltext.queryNodes).
The openCypher Technology Compatibility Kit (TCK) measures everything else; tests/tck/REPORT.md
gives the current pass rate per area.