Re: [Neo4j] Get Values from array parameter that does not match any node

15 views
Skip to first unread message

Lasse Westh-Nielsen

unread,
May 17, 2013, 1:57:57 AM5/17/13
to Neo4j User
Gabriel,


Regards,

Lasse




On Thu, May 16, 2013 at 5:46 PM, Gabriel Gutierrez <gutier...@gmail.com> wrote:
Hi guys, I'm new to neo4j and specially to cypher language

I have this challenge I need to retrieve all missing values from my graph database.
The input will be an String[] and the output should be String[] that are not yet stored.

@NodeEntity
class Person {
   @GraphId Long id
   @Indexed(unique = true) String name
}

class PersonRepository extends GraphRepository<Person> {
     //@Query("....") this is what I'm not sure how to do it
     String[] getMissingNames(String[] names);
}

So lets assume that I have 3 Person nodes already stored

Person: John
Person: Gabriel
Person: Dave

Then I will get a String[] of names holding a persons names..

String[] names = {"Gabriel", "Carlos", "Ana"};

I need to create those that are not yet in my database, by doing this

String[] missedNames = personRepository.getMissingNames(names);
List<Person> missingPersons = new ArrayList<Person>
for (String name: missedNames ) {
    missinPersons.add(new Person(name));
}
//Insert all missing persons at once
personRepository.save(missingPersons);

missedNames array should contain the values of Carlos and Ana

How can I achieve something like this?

Thanks on advance your comments.

--
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.
 
 

Gabriel Gutierrez

unread,
May 17, 2013, 2:53:04 PM5/17/13
to ne...@googlegroups.com
I'm looking to get values from the array that are NOT IN the database.

I know could use something like that, but how can I identify such values that are NOT, since they dont belong to a node, they are part of an input parameter that happens to be an array.

Regards,
Reply all
Reply to author
Forward
0 new messages