Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j Cypher Query "NOT IN" doesnt work, "IN" works

I try to create a cypher-query in my Java-Spring-Application which should answer the question "give all employees who did not create a item in item.nameList":

@Query("START it=node:__types__(className = 'de.my.domain.ItemCl') MATCH empl-[r:CREATE]->it WHERE (it.name NOT IN ({0})) RETURN DISTINCT empl")
List<Employee> findAllEmployeesWhoNeverCreatedItemFromItemNameList(List<String> itemNameList);

This query gives an "org.springframework.dao.InvalidDataAccessResourceUsageException" and marks the "NOT" as failure.

If I try the same query without NOT ("give all employees who did create a item in item.nameList", the query does what it should.

In this thread Peter Neubauer told that this "NOT IN" exists in cypher: https://groups.google.com/forum/#!topic/neo4j/_PehVUfGaIA

Any idea what is wrong?

like image 328
Patrick Avatar asked Sep 14 '13 02:09

Patrick


People also ask

How does query work in Neo4j?

If the query is not already in the Execution Plan Cache, the query is compiled into an execution plan in the Neo4j DBMS. The execution plan executes in the Neo4j DBMS to retrieve data. The Page Cache is used to hold the data in memory.

How can I improve my Neo4j performance?

Heap Sizing The size of the available heap memory is an important aspect for the performance of Neo4j. Generally speaking, it is beneficial to configure a large enough heap space to sustain concurrent operations. For many setups, a heap size between 8G and 16G is large enough to run Neo4j reliably.

WHAT IS WITH clause in Cypher?

The WITH clause allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next. It is important to note that WITH affects variables in scope.


1 Answers

NOT is a negation, so you have to do it like this:

WHERE NOT(it.name IN({0}))
like image 79
Eve Freeman Avatar answered Oct 22 '22 21:10

Eve Freeman