But the syntax is not correct, or?

MATCH (m:Page {node:'{*n1*}'}), (n:Page {node:'{*n2*}'})

-> remove the single quotes around the parameters.



On Sun, Nov 23, 2014 at 10:54 PM, Nigel Small <ni...@neotechnology.com>
wrote:

> Following on from Michael's reply: in py2neo 1.6, you can pass parameters
> like this:
>
> query = neo4j.CypherQuery(
>     graph_db,
>     """MATCH (m:Page {node:'{*n1*}'}), (n:Page {node:'{*n2*}'}),
>     p = shortestPath((m)-[*..20]->(n)) RETURN p"""
> )
> query.execute(*n1*=node1, *n2*=node2)
>
> In py2neo 2.0, this will instead be:
>
> graph_db.cypher.execute(
>     """MATCH (m:Page {node:'{*n1*}'}), (n:Page {node:'{*n2*}'}),
>     p = shortestPath((m)-[*..20]->(n)) RETURN p""",
>     {"*n1*": node1, "*n2*": node2}
> )
>
> Nigel
>
> On 23 November 2014 at 21:09, Michael Hunger <
> michael.hun...@neotechnology.com> wrote:
>
>> After adding the constraint / index, did you also change your query to
>> include the :Page label?
>>
>> CREATE CONSTRAINT ON (p:Page) ASSERT p.node IS UNIQUE;
>>
>> query = neo4j.CypherQuery(
>>     graph_db,
>>     """MATCH (m:Page {node:'%s'}), (n:Page {node:'%s'}),     p = 
>> shortestPath((m)-[*..20]->(n)) RETURN p""" % (node1, node2)
>> )
>>
>> Also I recommend not to use string substitution but cypher parameters
>>
>> MATCH (m:Page {node:{node1}}), (n:Page {node:{node2}})
>>
>> and then pass a dictionary with {'node1':node1, 'node2':node2}
>>
>>
>> On Sun, Nov 23, 2014 at 6:37 PM, Erika Arnold <era...@gmail.com> wrote:
>>
>>>
>>>> Thank you for your suggestions. The database is about 5.5G on disk.
>>>
>>> I turned off auto indexing and applied the constraint on node id, but
>>> saw no discernible difference in response time. Perhaps the culprit is the
>>> pathfinding algorithm?
>>>
>>> When I ask for the shortest path between two nodes that I know are
>>> directly connected, why does the query take the same amount of time as for
>>> a path with 5 connections? Shouldn't it stop as soon as it finds node2 in
>>> the list of linked pages for node1?
>>>
>>> Additionally, even after placing the database on a memory-optimized EC2
>>> server with 15G RAM, the query still takes 30 seconds. It doesn't appear to
>>> be at max memory or CPU usage.
>>>
>>> I'm baffled at what to optimize next.
>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to