Misc user docs fixes.

Reviewers: buda, mislav.bradac, teon.banek, florijan

Reviewed By: buda

Differential Revision: https://phabricator.memgraph.io/D947
This commit is contained in:
Matej Ferencevic 2017-10-31 11:03:15 +01:00
parent f655725f5d
commit cfa21a2392
4 changed files with 61 additions and 76 deletions

View File

@ -30,7 +30,7 @@ types. Following is a table of supported data types.
-----------|------------
`Null` | Denotes that the property has no value. This is the same as if the property does not exist.
`String` | A character string, i.e. text.
`Boolean` | A Boolean value, either `true` or `false`.
`Boolean` | A boolean value, either `true` or `false`.
`Integer` | An integer number.
`Float` | A floating-point number, i.e. a real number.
`List` | A list containing any number of property values of any supported type. It can be used to store multiple values under a single property name.

View File

@ -7,7 +7,7 @@ install the Docker engine on the system. Instructions how to install Docker
can be found on the
[official Docker website](https://docs.docker.com/engine/installation).
Memgraph Docker image was built with Docker version `1.12` and should be
compatible with all latter versions.
compatible with all later versions.
### Docker Import
@ -124,7 +124,7 @@ All of the parameters can also be found in `/etc/memgraph/memgraph.conf`.
[^1]: Maximum number of concurrent executions on the current CPU.
To find more about how to execute queries on Memgraph please proceed to
[Quick Start](quick-start.md).
**Quick Start**.
### Cleanup

View File

@ -34,18 +34,18 @@ following query.
Finding connected nodes can be achieved by using the query:
MATCH (node1) -[connection]- (node2) RETURN node1, connection, node2
MATCH (node1)-[connection]-(node2) RETURN node1, connection, node2
In addition to general pattern matching, you can narrow the search down by
specifying node labels and properties. Similarly, edge types and properties
can also be specified. For example, finding each node labeled as `Person` and
with property `age` being 42, is done with the following query.
MATCH (n :Person {age: 42}) RETURN n.
MATCH (n :Person {age: 42}) RETURN n
While their friends can be found with the following.
MATCH (n :Person {age: 42}) -[:FriendOf]- (friend) RETURN friend.
MATCH (n :Person {age: 42})-[:FriendOf]-(friend) RETURN friend
There are cases when a user needs to find data which is connected by
traversing a path of connections, but the user doesn't know how many
@ -55,22 +55,21 @@ with *variable path lengths*. Matching such a path is achieved by using the
traversing from `node1` to `node2` by following any number of connections in a
single direction can be achieved with:
MATCH (node1) -[r*]-> (node2) RETURN node1, r, node2
MATCH (node1)-[r*]->(node2) RETURN node1, r, node2
If paths are very long, finding them could take a long time. To prevent that,
a user can provide the minimum and maximum length of the path. For example,
paths of length between 2 and 4 can be obtained with a query like:
MATCH (node1) -[r*2..4]-> (node2) RETURN node1, r, node2
MATCH (node1)-[r*2..4]->(node2) RETURN node1, r, node2
It is possible to name patterns in the query and return the resulting paths.
This is especially useful when matching variable length paths:
MATCH path = () -[r*2..4]-> () RETURN path
MATCH path = ()-[r*2..4]->() RETURN path
More details on how `MATCH` works can be found
[here](https://neo4j.com/docs/developer-manual/current/cypher/clauses/match/).
Note that *named paths* are not yet supported.
The `MATCH` clause can be modified by prepending the `OPTIONAL` keyword.
`OPTIONAL MATCH` clause behaves the same as a regular `MATCH`, but when it
@ -109,11 +108,11 @@ When you want to get everything that was matched, you can use the `*`
This query:
MATCH (node1) -[connection]- (node2) RETURN *
MATCH (node1)-[connection]-(node2) RETURN *
is equivalent to:
MATCH (node1) -[connection]- (node2) RETURN node1, connection, node2
MATCH (node1)-[connection]-(node2) RETURN node1, connection, node2
`RETURN` can be followed by the `DISTINCT` operator, which will remove
duplicate results. For example, getting unique names of people can be achieved
@ -230,7 +229,7 @@ You can still use the `RETURN` clause to produce results after writing, but it
is not mandatory.
Details on which kind of data can be stored in *Memgraph* can be found in
[Storable Data Types](data-types.md) chapter.
**Storable Data Types** chapter.
#### CREATE
@ -239,7 +238,7 @@ is done by providing a pattern, similarly to `MATCH` clause.
For example, to create 2 new nodes connected with a new edge, use this query.
CREATE (node1) -[:edge_type]-> (node2)
CREATE (node1)-[:edge_type]->(node2)
Labels and properties can be set during creation using the same syntax as in
[MATCH](#match) patterns. For example, creating a node with a label and a
@ -269,7 +268,7 @@ This clause is used to delete nodes and edges from the database.
Example. Removing all edges of a single type.
MATCH () -[edge :type]- () DELETE edge
MATCH ()-[edge :type]-() DELETE edge
When testing the database, you want to often have a clean start by deleting
every node and edge in the database. It is reasonable that deleting each node
@ -328,7 +327,7 @@ created. In a way, this clause is like a combination of `MATCH` and `CREATE`.
Example. Ensure that a person has at least one friend.
MATCH (n :Person) MERGE (n) -[:FriendOf]-> (m)
MATCH (n :Person) MERGE (n)-[:FriendOf]->(m)
The clause also provides additional features for updating the values depending
on whether the pattern was created or matched. This is achieved with `ON
@ -336,7 +335,7 @@ CREATE` and `ON MATCH` sub clauses.
Example. Set a different properties depending on what `MERGE` did.
MATCH (n :Person) MERGE (n) -[:FriendOf]-> (m)
MATCH (n :Person) MERGE (n)-[:FriendOf]->(m)
ON CREATE SET m.prop = "created" ON MATCH SET m.prop = "existed"
For more details, click [this
@ -409,22 +408,22 @@ a custom implementation, based on the edge expansion syntax.
Finding the shortest path between nodes can be done using breadth-first
expansion:
MATCH (a {id: 723})-[r:Type \*bfs..10]-(b {id : 882}) RETURN *
MATCH (a {id: 723})-[r:Type *bfs..10]-(b {id: 882}) RETURN *
The above query will find all paths of length up to 10 between nodes `a` and `b`.
The edge type and maximum path length are used in the same way like in variable
length expansion.
To find only the shortest path, simply append LIMIT 1 to the RETURN clause.
To find only the shortest path, simply append `LIMIT 1` to the `RETURN` clause.
MATCH (a {id: 723})-[r:Type \*bfs..10]-(b {id : 882}) RETURN * LIMIT 1
MATCH (a {id: 723})-[r:Type *bfs..10]-(b {id: 882}) RETURN * LIMIT 1
Breadth-fist expansion allows an arbitrary expression filter that determines
if an expansion is allowed. Following is an example in which expansion is
allowed only over edges whose `x` property is greater then `12` and nodes `y`
whose property is lesser then `3`:
MATCH (a {id: 723})-[\*bfs..10 (e, n | e.x > 12 and n.y < 3)]-() RETURN *
MATCH (a {id: 723})-[*bfs..10 (e, n | e.x > 12 and n.y < 3)]-() RETURN *
The filter is defined as a lambda function over `e` and `n`, which denote the edge
and node being expanded over in the breadth first search.
@ -509,11 +508,11 @@ functions.
Apart from comparison and concatenation operators openCypher provides special
string operators for easier matching of substrings:
Operator | Description
-----------------|------------
a STARTS WITH b | Returns true if prefix of string a is equal to string b.
a ENDS WITH b | Returns true if suffix of string a is equal to string b.
a CONTAINS b | Returns true if some substring of string a is equal to string b.
Operator | Description
-------------------|------------
`a STARTS WITH b` | Returns true if prefix of string a is equal to string b.
`a ENDS WITH b` | Returns true if suffix of string a is equal to string b.
`a CONTAINS b` | Returns true if some substring of string a is equal to string b.
#### Parameters
@ -523,7 +522,7 @@ filtering results or similar, while the rest of the query remains the same.
Parameters allow reusing the same query, but with different parameter values.
The syntax uses the `$` symbol to designate a parameter name. We don't allow
old Cypher parameter syntax using curly brace. For example, you can parameterize
old Cypher parameter syntax using curly braces. For example, you can parameterize
filtering a node property:
MATCH (node1 {property: $propertyValue}) RETURN node1
@ -551,17 +550,17 @@ documentation.
#### CASE
Conditional expressions can be expressed in openCypher language by simple and
generic form of CASE expression. A simple form is used to compare an expression
generic form of `CASE` expression. A simple form is used to compare an expression
against multiple predicates. For the first matched predicate result of the
expression provided after the THEN keyword is returned. If no expression is
matched value following ELSE is returned is provided, or null if ELSE is not
expression provided after the `THEN` keyword is returned. If no expression is
matched value following `ELSE` is returned is provided, or `null` if `ELSE` is not
used:
MATCH (n)
RETURN CASE n.currency WHEN "DOLLAR" THEN "$" WHEN "EURO" THEN "€" ELSE "UNKNOWN" END
In generic form, you don't provided expression whose value is compared to
predicates, but you list multiple predicates and the first one that evaluates
In generic form, you don't need to provide an expression whose value is compared to
predicates, but you can list multiple predicates and the first one that evaluates
to true is matched:
MATCH (n)
@ -581,7 +580,7 @@ keywords (WHERE, MATCH, COUNT, SUM...).
#### Unicode Codepoints in String Literal
Use `\u` followed by 4 hex digits in string literal for UTF-16 codepoint and
'\U' with 8 hex digits for UTF-32 codepoint in Memgraph.
`\U` with 8 hex digits for UTF-32 codepoint in Memgraph.
### Difference from Neo4j's Cypher Implementation
@ -593,28 +592,20 @@ here (especially subtle semantic ones).
#### Unsupported Constructs
Data importing. Memgraph doesn't support Cypher's CSV importing capabilities.
The `UNION` keyword for merging query results.
The `FOREACH` language construct for performing an operation on every list element.
The `CALL` construct for a standalone function call. This can be expressed using
`RETURN functioncall()`. For example, with Memgraph you can get information about
the indexes present in the database using the `RETURN indexinfo()` openCypher query.
Stored procedures.
Regular expressions for string matching.
`shortestPath` and `allShortestPaths` functions. `shortestPath` can be expressed using
Memgraph's breadth-first expansion syntax already described in this document.
Patterns in expressions. For example, Memgraph doesn't support `size((n)-->())`. Most of the time
the same functionalities can be expressed differently in Memgraph using `OPTIONAL` expansions,
function calls etc.
Map projections such as `MATCH (n) RETURN n {.property1, .property2}`.
* Data importing. Memgraph doesn't support Cypher's CSV importing capabilities.
* The `UNION` keyword for merging query results.
* The `FOREACH` language construct for performing an operation on every list element.
* The `CALL` construct for a standalone function call. This can be expressed using
`RETURN functioncall()`. For example, with Memgraph you can get information about
the indexes present in the database using the `RETURN indexinfo()` openCypher query.
* Stored procedures.
* Regular expressions for string matching.
* `shortestPath` and `allShortestPaths` functions. `shortestPath` can be expressed using
Memgraph's breadth-first expansion syntax already described in this document.
* Patterns in expressions. For example, Memgraph doesn't support `size((n)-->())`. Most of the time
the same functionalities can be expressed differently in Memgraph using `OPTIONAL` expansions,
function calls etc.
* Map projections such as `MATCH (n) RETURN n {.property1, .property2}`.
#### Unsupported Functions

View File

@ -10,6 +10,14 @@ Memgraph supports the openCypher query language which has been developed by
vendor-independent standardization process. It's a declarative language
developed specifically for interaction with graph databases.
### Multiple-Query Transactions
Memgraph supports transactions containing multiple queries. In other words,
one can set an explicit transaction start and stop. All of the queries inside
will be executed as a single transaction. This means that if a single query
execution fails, all of the executed queries will be reverted and the
transaction aborted.
### Bolt
Clients connect to Memgraph using the
@ -46,9 +54,9 @@ neo4j-client bolt://<IP_ADDRESS>:<PORT> --insecure --user u --pass p
Where `<IP_ADDRESS>` and `<PORT>` should be replaced with the network location
where Memgraph is reachable. The `--insecure` option specifies that SLL should
be disabled (Memgraph alpha does not support SSL). `--user` and `--pass`
parameter values are ignored by Memgraph (alpha is single-user), but need to
be provided for the client to connect automatically.
be disabled (Memgraph currently does not support SSL). `--user` and `--pass`
parameter values are ignored by Memgraph (currently the database is
single-user), but need to be provided for the client to connect automatically.
After the client has started it should present a command prompt similar to:
@ -171,10 +179,10 @@ can be disabled by passing `{encrypted: 'ENCRYPTION_OFF'}` during the driver
construction.
Here is an example related to `Node.js`. Memgraph doesn't have integrated
support for `Web Socket` which is required during the execution in any web
support for `WebSocket` which is required during the execution in any web
browser. If you want to run `openCypher` queries from a web browser,
[websockify](https://github.com/novnc/websockify) has to be up and running.
Requests from web browsers are wrapped into `Web Socket` messages, and a proxy
Requests from web browsers are wrapped into `WebSocket` messages, and a proxy
is needed to handle the overhead. The proxy has to be configured to point out
to Memgraph's Bolt port and web browser driver has to send requests to the
proxy port.
@ -217,23 +225,9 @@ run_query("MATCH (n) DETACH DELETE n", function (result) {
### Limitations
Memgraph is currently in alpha stage, and has a number of limitations we plan
Memgraph is currently in early stage, and has a number of limitations we plan
to remove in future versions.
#### Single query length
The maximum length of a query that can be sent from a driver in Python is
`16378` characters, from a driver in Java `8184` and from a driver in
JavaScript `1392` characters.
#### Multiple-Query Transactions
Even though Memgraph is a transactional database engine, transactions
containing multiple queries are not yet supported. In other words, explicit
transaction start and stop aren't yet supported. A transaction is created and
committed implicitly for each executed query. If query execution fails, the
transaction is aborted.
#### Multiple Users & Authorization
Memgraph is currently single-user only. There is no way to control user
@ -248,7 +242,7 @@ Memgraph processes.
#### Secure Sockets Layer (SSL)
Secure connections are not supported in alpha. For this reason each client
Secure connections are not supported. For this reason each client
driver needs to be configured not to use encryption. Consult driver-specific
guides for details.