# Unble to fetch nodes with optional relationships

**URL:** <https://community.neo4j.com/t/unble-to-fetch-nodes-with-optional-relationships/42087>\
**Category:** Neo4j Graph Platform\
**Created:** [July 28, 2021, 12:21am UTC](https://community.neo4j.com/t/unble-to-fetch-nodes-with-optional-relationships/42087 "2021-07-28T00:21:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishalkpatel](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/vishalkpatel/32/4137_2.png) [@vishalkpatel](https://community.neo4j.com/u/vishalkpatel)\
**Post date:** [July 28, 2021, 12:21am UTC](https://community.neo4j.com/t/unble-to-fetch-nodes-with-optional-relationships/42087/1 "2021-07-28T00:21:23Z")

</div>

Say I want nodes whoes fields are OPTIONALLY matching with text as well related nodes' fields are OPTIONALLY matching with the same text.

For example, I have node: Qualifications with name and description fields. I have node:Tag with tag field. Relation betwwen these 2 is `(:Qalification)-[:TAGGED_AS]->(:Tag)`

I need all Node:Qualification if qualification.name OR qualidication.description OR (if qualification is tagged, tag.tag) CONTAINS $text

I tried below. But it does not match if NO RELATION found.  
``

`
match (q:Qualification)-[ta:TAGGED_AS]->(t:TAG), (q1:Qualification) WHERE (toLower(q.name) CONTAINS "derm" OR toLower(q.description) CONTAINS "derm" OR t.searchableTag CONTAINS "derm") AND (toLower(q1.name) CONTAINS "derm" OR toLower(q1.description) CONTAINS "derm") return q,ta,t,q1
`

---

<div class="post-metadata">

**Author:** ![Bennu](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/bennu/32/11659_2.png) [@Bennu](https://community.neo4j.com/u/Bennu)\
**Post date:** [July 28, 2021, 10:54am UTC](https://community.neo4j.com/t/unble-to-fetch-nodes-with-optional-relationships/42087/2 "2021-07-28T10:54:13Z")

</div>

Hi @vishalkpatel ,

I would rather suggest a UNION approach.

Something like next query should work:

```auto
MATCH (q:Qualification)
WHERE (toLower(q.name) CONTAINS "derm" 
    OR toLower(q.description) CONTAINS "derm" ) 
return q
UNION
MATCH (q:Qualification)-[:TAGGED_AS]->(t:Tag)
WHERE t.searchableTag CONTAINS "derm"
return q

```

Be aware of the fact that using toLower on query will prevent the planner from using indexes on those propierties.

Hoping to be useful,

H
