Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
cypher query to connect a where clause with the elements of an array
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 42 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
divyanshu das  
View profile  
 More options Nov 7 2012, 3:43 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Wed, 7 Nov 2012 12:43:58 -0800 (PST)
Local: Wed, Nov 7 2012 3:43 pm
Subject: cypher query to connect a where clause with the elements of an array

I have neo4j 1.6.1 and I am using php .

I have an array "arr" of a particular property "prop" of nodes.

I want to delete all nodes from neo4j having a certain relationship "rel"
except for the nodes whose property "prop" is in the array "arr".

Can somebody help me out with this?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 7 2012, 3:55 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Wed, 7 Nov 2012 15:54:40 -0500
Local: Wed, Nov 7 2012 3:54 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

You can't delete via Cypher with that version of Neo.

If you want to just find them, you could do something like (I'm not
entirely sure this worked back then, either--you might consider upgrading):

start n=node(*)
where n.prop in n.arr
return n;

Wes

On Wed, Nov 7, 2012 at 3:43 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 7 2012, 4:10 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Wed, 7 Nov 2012 16:09:54 -0500
Local: Wed, Nov 7 2012 4:09 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

I guess that's not exactly what you asked for... how about this:

http://console.neo4j.org/r/xg5y9u

start n=node(*)
match n-[:rel]->()
where has(n.arr) and not(n.prop in n.arr)
return n;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 7 2012, 4:12 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Wed, 7 Nov 2012 13:12:51 -0800 (PST)
Local: Wed, Nov 7 2012 4:12 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Hey, thanks for prompt replies. If I am correct, node(*) method is not
available in 1.6.1. Any workaround  for this?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 7 2012, 4:16 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Wed, 7 Nov 2012 16:16:08 -0500
Local: Wed, Nov 7 2012 4:16 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

I guess you could use the reference node, and consider that in your match.
Sorry, I'm new to Neo as of 1.8 for the most part.

Wes

On Wed, Nov 7, 2012 at 4:12 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 7 2012, 4:18 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Wed, 7 Nov 2012 13:18:53 -0800 (PST)
Local: Wed, Nov 7 2012 4:18 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

If I upgrade to 1.8, then I get the delete queries. Now, If I delete the
nodes, will the node ids for other users remain unchanged or neo4j
automatically reuses the deleted ids?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 7 2012, 4:26 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Wed, 7 Nov 2012 16:26:29 -0500
Local: Wed, Nov 7 2012 4:26 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

It isn't a good idea to depend on node ids for long term use (rather, use
an email address or guid or similar unique id, with an index). Ids are
reused after you restart the server, I think, if they were deleted.

Wes

On Wed, Nov 7, 2012 at 4:18 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 7 2012, 4:36 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Wed, 7 Nov 2012 13:36:49 -0800 (PST)
Local: Wed, Nov 7 2012 4:36 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Is there any other way to delete nodes in 1.6.1 without using cypher
queries?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 7 2012, 4:53 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Wed, 7 Nov 2012 16:52:52 -0500
Local: Wed, Nov 7 2012 4:52 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Well, I think the REST delete commands existed in 1.6 if you're using
server. If you're using embedded, you can do it like this:
http://docs.neo4j.org/chunked/stable/tutorials-java-embedded-hello-wo...

On Wed, Nov 7, 2012 at 4:36 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 11:55 am
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 08:55:02 -0800 (PST)
Local: Thurs, Nov 8 2012 11:55 am
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

@Freeman, The code that you gave works for array when it is in neo4j.

I have a separate php array that I am fetching from mysql.

I need to delete the nodes and relationships for nodes whose certain
property matches the values stored in thee array.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 8 2012, 12:17 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Thu, 8 Nov 2012 12:17:20 -0500
Local: Thurs, Nov 8 2012 12:17 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

You can also specify a literal array in cypher... not sure what you're
using from PHP, but you can do something like this via REST:
{query:"start n=node(*)
match n-[:rel]->()
where not(n.prop in {phparr})
return n;", params:{phparr:[1,2,3]}}

On Thu, Nov 8, 2012 at 11:55 AM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 12:25 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 09:25:25 -0800 (PST)
Local: Thurs, Nov 8 2012 12:25 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

I am using cypher queries as mentioned in
https://github.com/jadell/neo4jphp/wiki/Cypher-and-gremlin-queries

my phparray is $result_array, so will the query look like this?

$queryTemplate = "START n = node(*) MATCH n-[:rel]->() WHERE not(n.prop in
{phparr}) Return n", params:{phparra:$result_array};


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 8 2012, 12:40 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Thu, 8 Nov 2012 12:39:35 -0500
Local: Thurs, Nov 8 2012 12:39 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

They have an example there with a parameter using the constructor...

$queryString = "start n=node(*) ".    "match n-[:rel]->() ".    "where
not(n.prop in {phparr}) ".    "return n";$query = new
Everyman\Neo4j\Cypher\Query($client, $queryString, array('phparr' =>
$result_array));$result = $query->getResultSet();

I'm assuming it knows how to convert a php array to a json array, but maybe
that's not a good assumption. If it doesn't, you might have to do something
like http://php.net/manual/en/function.json-encode.php to convert your php
array to a json non-associative array.

On Thu, Nov 8, 2012 at 12:25 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 1:00 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 10:00:19 -0800 (PST)
Local: Thurs, Nov 8 2012 1:00 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

hey thanks. I saw this example after I posted the last reply.

Now, when i run this query for a particular node "abc" it just returns the
the node "abc" multiple times(i guess no. of nodes which are not in that
array).

If I run the query with node(*), it fails at node 0. giving the message:- The
property 'prop' does not exist on Node[0].

How do I skip checking at node 0.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 1:07 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 10:07:03 -0800 (PST)
Local: Thurs, Nov 8 2012 1:07 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

I modified to query like this:-

WHERE has(n,prop) AND not(n.prop in {phparr})


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 1:17 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 10:17:44 -0800 (PST)
Local: Thurs, Nov 8 2012 1:17 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

It gave me this error after running for 10 mins,

Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message
'Unable to execute query [100]: Headers: Array ( ) Body: Array ( ) ' in
/var/www/new-ui/app/libs/Everyman/Neo4j/Command.php:117 Stack trace: #0
/var/www/new-ui/app/libs/Everyman/Neo4j/Command/ExecuteCypherQuery.php(85):
Everyman\Neo4j\Command->throwException('Unable to execu...', 100, Array,
Array) #1 /var/www/new-ui/app/libs/Everyman/Neo4j/Command.php(70):
Everyman\Neo4j\Command\ExecuteCypherQuery->handleResult(100, Array, Array)
#2 /var/www/new-ui/app/libs/Everyman/Neo4j/Client.php(602):
Everyman\Neo4j\Command->execute() #3
/var/www/new-ui/app/libs/Everyman/Neo4j/Client.php(164):
Everyman\Neo4j\Client->runCommand(Object(Everyman\Neo4j\Command\ExecuteCyph erQuery))
#4 /var/www/new-ui/app/libs/Everyman/Neo4j/Cypher/Query.php(65):
Everyman\Neo4j\Client->executeCypherQuery(Object(Everyman\Neo4j\Cypher\Quer y))
#5 /var/www/new-ui/app/services/users_service.php(106):
Everyman\Neo4j\Cypher\Query->getResultSet() #6
/var/www/new-ui/app/controllers/users_contro in
/var/www/new-ui/app/libs/Everyman/Neo4j/Command.php on line 117


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Montag  
View profile   Translate to Translated (View Original)
 More options Nov 8 2012, 1:33 pm
From: David Montag <david.mon...@neotechnology.com>
Date: Thu, 8 Nov 2012 10:31:15 -0800
Local: Thurs, Nov 8 2012 1:31 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Just want to jump in here. The current workaround for deleting indexed
nodes with Cypher requires you to know what indexes the node is indexed in,
and for which property keys and values it is indexed. You can then delete
the node, and then look it up in all indexes where it was previously
indexed. This will not return any results, but it will trigger the
necessary cleanup of the index.

David

On Wed, Nov 7, 2012 at 1:36 PM, divyanshu das <divyanshu....@gmail.com>wrote:

--
David Montag <david.mon...@neotechnology.com>
Neo Technology, www.neotechnology.com
Cell: 650.556.4411
Skype: ddmontag

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 1:42 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 10:42:29 -0800 (PST)
Local: Thurs, Nov 8 2012 1:42 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

thnx for pointing this out. But I did not quite understand it. Does this
mean, that if I replace "return" by "delete" it wont delete the nodes?

However, right now, I  want to return those nodes first so that I can check
if I am actually deleting the right node.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 8 2012, 2:03 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Thu, 8 Nov 2012 14:03:04 -0500
Local: Thurs, Nov 8 2012 2:03 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Put a "where has(n.prop)" in the query. Or where not(id(n) = 0), if that's
the only one.

Wes

On Thu, Nov 8, 2012 at 1:00 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 8 2012, 2:51 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Thu, 8 Nov 2012 14:51:10 -0500
Local: Thurs, Nov 8 2012 2:51 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

It will. David is just saying (in response to the question about how to
delete in cypher, earlier in the thread) that if you have indexes on those
nodes (do you?), you should query the indexes on the particular fields that
are indexed so the indexes get cleaned up, afterward. You also need to
delete the relationships connected to those nodes at the same time (else
you'll get an error about not being able to delete nodes with
relationships), so you might end up with something like "match n-[r?]-()
... delete n,r;"

I'm not sure what the PHP error is coming from--I'm not much of a PHP guy,
myself. Is this a single command that's failing after 10 minutes, or are
you iterating through some list of arrays and it's failing on one of the
particular arrays?

On Thu, Nov 8, 2012 at 1:42 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 3:19 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 12:19:18 -0800 (PST)
Local: Thurs, Nov 8 2012 3:19 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Yes, I do have indexes.

this is the query I am using:- $queryTemplate = "START n = node(*) MATCH
n-[:rel]->b WHERE has(n.prop) AND not(b.prop in {phparr}) RETURN b";
phparr is one single array.

Ideally this query should return all the list of nodes "b" , which has a
"rel" relationship and b.prop is not an element of array.
But it gives the error I pasted earlier

If I use this query:- $queryTemplate = "START n = node(1239147) MATCH
n-[:rel]->b WHERE (n.prop in {phparr}) RETURN b";

I get nodes with b.prop in the array.

But when I use this query with a "not" in where clause it gives no results.
I have tried it with 10 nodes. everytime zero results.

My db has 6 million nodes, and 1645 have property "prop"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wes Freeman  
View profile  
 More options Nov 8 2012, 3:25 pm
From: Wes Freeman <freeman....@gmail.com>
Date: Thu, 8 Nov 2012 15:25:00 -0500
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Your queries might be mixing up the "n" and "b" identifiers. I think you
mean:
"has(b.prop) and not(b.prop in {phparr})"

Wes

On Thu, Nov 8, 2012 at 3:19 PM, divyanshu das <divyanshu....@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 3:29 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 12:29:33 -0800 (PST)
Local: Thurs, Nov 8 2012 3:29 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Correction:-

db has 6 million nodes more than 2-3 millions have "prop" property. I need
to delete all those nodes with "prop" property and "rel" relationship whose
"prop" is not listed in phparr.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 8 2012, 3:42 pm
From: divyanshu das <divyanshu....@gmail.com>
Date: Thu, 8 Nov 2012 12:42:45 -0800 (PST)
Local: Thurs, Nov 8 2012 3:42 pm
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

the database is designed in a way that, if a node has "rel" relationship
it'll have "prop" property too.

has(n.prop) is just to check if starting node has "prop" property.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
divyanshu das  
View profile  
 More options Nov 9 2012, 6:11 am
From: divyanshu das <divyanshu....@gmail.com>
Date: Fri, 9 Nov 2012 03:11:52 -0800 (PST)
Local: Fri, Nov 9 2012 6:11 am
Subject: Re: [Neo4j] cypher query to connect a where clause with the elements of an array

Ok. so finally the query the completed, and shows me the desired results if
I specify node numbers.

But it fails for node(8). I am assuming its some memory management issue.
Right now, I dont have time to get into this.

Can someone tell me, how do I pass an array or list as an argument for
start node. Something like,

start n = node(array of nodes)
Since I am already passing an array, so it will be second array. Is paasing
of two arrays allowed in the same query?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 42   Newer >
« Back to Discussions « Newer topic     Older topic »