Skip to content

Commit ec34278

Browse files
authored
Merge pull request #4 from opsdis/query_support
Query support
2 parents f034555 + 9b9917b commit ec34278

2 files changed

Lines changed: 89 additions & 134 deletions

File tree

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,23 @@ All endpoint expects the header "Content-Type" set to "application/json"
8484

8585
## Data source API
8686

87-
GET /{graph_schema}/api/graph/data
87+
GET /{graph_schema}/api/graph/data?query=<WHERE clause>
88+
The above query parameter is optional, If empty or not set all nodes and edges are returned.
89+
If set, it must be a valid Cypher statement, https://neo4j.com/docs/cypher-manual/current/clauses/where/,
90+
but with some limitation documented in https://neo4j.com/docs/cypher-manual/current/clauses/where/.
91+
For example the Redis Cypher do not support regular expression.
92+
93+
> The `WHERE` should not be part of the query string, and the string must be urlencoded.
94+
95+
The WHERE clause can only operate where source nodes, edges and target nodes are returned, e.g.
96+
the statement `edge.mainStat > 0` will be in encoded url:
97+
98+
query=edge.mainStat%20%3E%200
99+
100+
The source nodes are referred to as `source`, target nodes are referred to as `target` and edges are
101+
referred to as `edge`
102+
103+
88104
GET /{graph_schema}/api/graph/fields
89105
GET /{graph_schema}/api/health
90106

@@ -141,7 +157,7 @@ model, this is the most effective endpoint to use.
141157
>
142158
> DELETE /api/graphs/{graph_schema}
143159

144-
The POST endpoint requiere a body of a list of nodes and edges, e.g.
160+
The POST endpoint require a body of a list of nodes and edges, e.g.
145161
```json
146162
{
147163
"nodes": [
@@ -179,9 +195,6 @@ The following api are deprecated:
179195
POST /api/controller/{graph_schema}/delete-all
180196

181197

182-
183-
184-
185198
## Return status
186199

187200
- 200
@@ -209,7 +222,7 @@ Start redis with module RedisGraph. Simple way just use docker.
209222

210223
docker run -p 6379:6379 redislabs/redismod
211224

212-
Start nodegraph-provider
225+
Start nodegraph-provider, configuration file is default `config.yml`
213226

214227
go build -o build/nodegraph-provider *.go
215228
./build/nodegraph-provider
@@ -232,7 +245,8 @@ Or run the example to create a complete graph:
232245

233246
./examples/setup_graph.sh
234247

235-
In Grafana you should now see this.
248+
In Grafana you should now see this graph.
249+
236250
![Initial Graph](docs/graph_1.png?raw=true "Start graph")
237251

238252
Add a new node with id `cust-svc-2`
@@ -252,8 +266,14 @@ Update metrics on edge between `lb-1` to `cust-svc-1
252266
curl -s -i -H "Content-Type: application/json" -X PUT "localhost:9393/api/edges/micro/lb-1/cust-svc-1?mainStat=$RANDOM&secondaryStat=$RANDOM"
253267

254268
You should now see something like this.
269+
255270
![Updated Graph](docs/graph_2.png?raw=true "Updated graph")
256271

272+
Delete the whole graph
273+
274+
curl -s -i -H "Content-Type: application/json" -X DELETE "localhost:9393/api/graph/micro"
275+
276+
257277
# Build docker
258278
Use the Dockerfile in the root directory of the project
259279

0 commit comments

Comments
 (0)