# Neovis Cypher query behaviour different to the Neo4J browser

**URL:** <https://community.neo4j.com/t/neovis-cypher-query-behaviour-different-to-the-neo4j-browser/13720>\
**Category:** Cypher\
**Tags:** cypher\
**Created:** [January 17, 2020, 9:17am UTC](https://community.neo4j.com/t/neovis-cypher-query-behaviour-different-to-the-neo4j-browser/13720 "2020-01-17T09:17:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliver.richardson1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/oliver.richardson1/32/4446_2.png) [@oliver.richardson1](https://community.neo4j.com/u/oliver.richardson1)\
**Post date:** [January 17, 2020, 9:17am UTC](https://community.neo4j.com/t/neovis-cypher-query-behaviour-different-to-the-neo4j-browser/13720/1 "2020-01-17T09:17:52Z")

</div>

I've created a NeoVis based on the example given here: [NeoVis Form Example](https://github.com/neo4j-contrib/neovis.js/blob/master/examples/form-example.html)

I've adapted it a little bit - but I really am simply passing a Cypher query in as a string - and for the most part it works completely as expected.

But I have one important scenario where the Cypher results are not as expected. Moreover, in this scenario alone, they are different to the results obtained running the same Cypher in the Neo4J browser.

Here is the Cypher query I'm dealing with:  
`MATCH (n: Question) WHERE n.question_id = "9377398" OPTIONAL MATCH (n: Question)-[r:connected]->(m: Theme) WHERE n.question_id = "9377398" RETURN n, r, m`

The node that is matched, namely the node of Label 'Question' having question\_id "9377398", does NOT currently have any relationships to any nodes of Label 'Theme', and so it is the first MATCH clause (rather than the subsequent OPTIONAL MATCH clause) that returns results, and hence it is only the "n" part of the RETURN clause that is not null.

When we run the Neo4J browser, we find (as expected) results consisting of one node of Label 'Question' having question\_id "9377398" (and no relationships, etc).

By contrast, when we run via the NeoVis implementation, NO results at all are returned. Yet, when we amend the query as follows:  
`MATCH (n: Question) WHERE n.question_id = "9377398" OPTIONAL MATCH (n: Question)-[r:connected]->(m: Theme) WHERE n.question_id = "9377398" RETURN n`

... in other words we have explicitly removed the possibility to return any relationships and connected nodes, should they exist, then in that case the NeoVis implementation now successfully returns just the one node of Label 'Question' having question\_id "9377398" (and no relationships, etc).

I would appreciate any assistance in either making adjustments to my NeoVis implementation to align its behaviour with the Neo4J browser or otherwise assistance in constructing a Cypher query which will be robust to this issue (NB// I have attempted to do like `MATCH ... RETURN n UNION MATCH ... RETURN n, r, m` yet even then, the NeoVis implementation won't return anything 🤔)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![shan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/shan/32/7767_2.png) [@shan](https://community.neo4j.com/u/shan)\
**Post date:** [January 17, 2020, 4:37pm UTC](https://community.neo4j.com/t/neovis-cypher-query-behaviour-different-to-the-neo4j-browser/13720/2 "2020-01-17T16:37:23Z")

</div>

Hi @oliver.richardson1

I tried to reproduce this by adding a single node with Label `Question` and `question_id="9377398"`. And then used your query to test it. Both NeoVis and Neo4j admin console returned the node. There might be something else that causes this for you.
