Skip to content

Commit 29f3cf7

Browse files
Add notifications info.
1 parent 6653842 commit 29f3cf7

File tree

1 file changed

+44
-14
lines changed

1 file changed

+44
-14
lines changed

modules/ROOT/pages/query.adoc

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,40 +374,70 @@ Content-Type: application/json;charset=utf-8
374374
====
375375

376376

377-
== Query parameters
377+
== Server notifications
378378

379-
In order to speed up queries in repeated scenarios, avoid using literals and replace them with parameters wherever possible.
380-
This allows the server to cache query plans and can result in a significant performance improvement.
379+
If the server generates any link:{neo4j-docs-base-uri}/status-codes/current/notifications[notifications], they will be returned in the `notifications` key of the response object (as a list).
380+
Notifications include recommendations for performance improvements, warnings about the usage of deprecated features, and other hints about sub-optimal usage of Neo4j.
381+
382+
====
383+
[discrete]
384+
=== Example request
385+
386+
[source, headers]
387+
----
388+
POST http://localhost:7474/db/neo4j/tx/commit
389+
Accept: application/json;charset=UTF-8
390+
Content-Type: application/json
391+
Authorization: Basic bmVvNGo6dmVyeXNlY3JldA==
392+
----
381393
382-
.Do -- Use query parameters
383394
[source, JSON]
384395
----
385396
{
386397
"statements": [
387398
{
388-
"statement": "MERGE (n:Person {name: $name, age: $age}) RETURN n",
399+
"statement": "MATCH p=shortestPath((:Person {name: $from})-[*]->(:Person {name: $to})) RETURN p",
389400
"parameters": {
390-
"name": "Alice",
391-
"age": 42
401+
"from": "Alice",
402+
"to": "Bob"
392403
}
393404
}
394405
]
395406
}
396407
----
397408
398-
.Do not -- Embed literals in query
399-
[source, JSON]
409+
[discrete]
410+
=== Example response
411+
412+
[source, headers]
413+
----
414+
200: OK
415+
Content-Type: application/json;charset=utf-8
416+
----
417+
418+
[source, JSON, role=nocollapse]
400419
----
401420
{
402-
"statements": [
421+
"results": [
422+
...
423+
],
424+
"notifications": [
403425
{
404-
"statement": "MERGE (n:Person {name: 'Alice', age: 42}) RETURN n",
426+
"code": "Neo.ClientNotification.Statement.UnboundedVariableLengthPattern",
427+
"severity": "INFORMATION",
428+
"title": "The provided pattern is unbounded, consider adding an upper limit to the number of node hops.",
429+
"description": "Using shortest path with an unbounded pattern will likely result in long execution times. It is recommended to use an upper limit to the number of node hops in your pattern.",
430+
"position": {
431+
"offset": 21,
432+
"line": 1,
433+
"column": 22
434+
}
405435
}
406-
]
436+
],
437+
...
407438
}
408439
----
409-
410-
See link:{neo4j-docs-base-uri}/cypher-manual/current/syntax/parameters/[Cypher Manual -> Parameters] for more information.
440+
====
411441

412442

413443
ifndef::backend-pdf[]

0 commit comments

Comments
 (0)