multiple queries in one cypher statement over rest

Showing 1-8 of 8 messages
multiple queries in one cypher statement over rest Shahar Taite 9/11/13 1:47 AM
Hey guys,
i'm creating a generator for cypher queries, and i would like to be able to send a bunch of queries in one cypher statement throught the rest API but using the cypher address(http://localhost:7474/db/data/cypher)
is there any way of diffrentiating the different queries in one cypher so i can just send it as one piece to http://localhost:7474/db/data/cypher and it will run one after the other?


example for such query:

Create(n1{Type:'Person',Lname:'Taite',Fname:'Shahar'})
Start A3=node(*), B3=node(*) 
Where A3.Type='Person'
and A3.Lname='Taite' 
and A3.Fname='Shahar' 
and B3.Type='Term' 
and B3.Text='Software' 
Create(A3)-[:Knows {}]->(B3)
Re: [Neo4j] multiple queries in one cypher statement over rest Michael Hunger 9/11/13 2:03 AM
You can already combine your two queries into one:

Create(n1{Type:'Person',Lname:'Taite',Fname:'Shahar'})
    WITH n1 
Start  B3=node(*) 
and B3.Type='Term' 
and B3.Text='Software' 
Create(n1)-[:Knows {}]->(B3)

You would also want to try an index lookup for the B3 node instead of scanning the whole database.
Either with a start clause too (1.9) or with a label based index in Neo4j 2.0 match B3:Term where B3.Text='Software' (index would be: create index on :Term(text); )

Which Neo4j version are you using?

With Neo4j 2.0 there is the transactional http endpoint which allows that.

In Neo4j 1.9 you can use the batch-rest-operations.

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: [Neo4j] multiple queries in one cypher statement over rest Shahar Taite 9/16/13 1:29 AM
i'm using Neo4j 1.9.2
i checked out the batch-rest-operations but i would like to stick to Cypher queries , is there any option for batch operations using cypher queries?
thanks
Re: [Neo4j] multiple queries in one cypher statement over rest Michael Hunger 9/16/13 1:39 AM
Sure,

works the same way.

Just use /db/data/cypher as "to" and "body" : { "query" : "start ...", "params" : {"param1","value1"} }

HTH

Michael
Re: [Neo4j] multiple queries in one cypher statement over rest Shahar Taite 9/16/13 1:44 AM
oh and can you point me to a link of how to do the "start clause too" you were mentioning?
thanks
Re: [Neo4j] multiple queries in one cypher statement over rest Michael Hunger 9/16/13 1:49 AM
Re: [Neo4j] multiple queries in one cypher statement over rest Shahar Taite 9/16/13 1:52 AM
oh ok i got what you meant.
great help Michael 
thanks so much
great to see there is help here when i need it
Re: [Neo4j] multiple queries in one cypher statement over rest Michael Hunger 9/16/13 2:00 AM
You're welcome,

you can also try the batching cypher statements in the HTTP shell

just use something like this


POST /db/data/batch [{"id":0, "to":"/db/data/cypher", "method":"POST", "body" : { "query" : "start n=node:node_auto_index(name={param1}) return n", "params" : {"param1":"value1"} }}]