cypher


Return only one Boolean Row in Cypher instead of Null


I have a graph with nodes like 'Persons' and relationships called 'RELATION' with a dynamic type like 'BIOLOGICAL_MOTHER'.
To check if a person is in a parent-role i want to use one cypher-query that return one boolean row, instead of NULL or something else.
I use Spring Data Neo4j 4 and this is the following method in the person-repository:
#Query("OPTIONAL MATCH (child)-[r:RELATION]->(parent) " +
"RETURN DISTINCT " +
"CASE " +
"WHEN id(parent)={0} AND r IS NOT NULL AND (r.type='BIOLOGICAL_MOTHER' OR r.type='BIOLOGICAL_FATHER') " +
"THEN true " +
"ELSE false " +
"END")
boolean isParentRole(long id);
If i query this on a parent person, the following error returns :
More than one element in org.neo4j.helpers.collection.IterableWrapper
$MyIteratorWrapper#235ecd9f.
First element is 'true' and the second element is 'false'
How can i use "OR" of all result-rows, to return only one row (in this case true)?
I solve my problem with this query:
#Query("OPTIONAL MATCH (child)-[r:RELATION]->(parent) " +
"WITH (CASE WHEN id(parent)={0} AND r IS NOT NULL " +
"AND (r.type='BIOLOGICAL_MOTHER' OR r.type='BIOLOGICAL_FATHER') THEN true ELSE false END) as check " +
"RETURN ANY (x in collect(check) WHERE x=true) ")
boolean isParentRole(long id);
If an easier way solve my problem, please comment.

Related Links

How do I do a WHERE clause on a COUNT in Cypher?
Cypher: WITH is required between CREATE and MATCH
Cypher - Maximum Connected Common Subgraph
loading the csv file via https, Cypher error
Cypher syntax highlighting in a text area?
How to find the node with outgoing relationship but no relationship on 2nd degree nodes
How to add weight as label to vertex?
combining the same nodes in different columns neo4j
cypher delete node and all the list of related node
Ne04j Cypher: Selecting a node as per relationship in EXTRACT with WHEN CASE
Issue utilizing OrderBy With Neo4jClient
Match variable length path while limiting node type
Cypher query loading complex CSV file
ORDER BY and the event horizon
Get all nodes that do not have a specific relation
How to use CASE to create composite score in Cypher

Categories

HOME
orientdb
memory
list
opencart
functional-programming
angular-ui-grid
seedstack
livecode
dafny
jersey-2.0
tcp
dependencies
elk-stack
hyperledger
openfoam
phpmqtt
graphql-js
jpa-criteria
fasm
fbloginview
angular4
stimulsoft
distributed-computing
dma
android-5.1.1-lollipop
kaggle
multi-upload
uislider
generator
websphere-portal
ava
animated-gif
software-packaging
environment
router
webviewclient
credit-card
caesar-cipher
wdk
numerics
jade4j
nanogallery
macports
elastica
llvm-ir
recovery
export-to-pdf
flipkart
permission-denied
rightnow-crm
photoswipe
nusoap
redisson
test-data
dymola
sidewaffle
cocoa-bindings
pjax
java-2d
dmarc
dpkg
qpixmap
static-methods
wicked-pdf
urbit
xcopy
teamviewer
wif4.5
wepay
in-app-billing
apple
replicaset
vdm-sl
erlog
web-api
deque
android-audiomanager
signed
dc
global-scope
full-text-indexing
accessory
thruway
accountmanager
property-injection
jms-serializer
django-settings
insertion
axacropdf
web-frameworks
itunes-sdk
zend-pdf
stretch
android-dialog
cakeyframeanimation
monocross
winsxs
fragment-identifier
jmenu
wmd-editor
.net-client-profile
database-cloning

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App