Reference to the above image, nodes on the left are "Label_1", nodes on the right are "Label_2". On Label_2, the node which has the properth "F"(the middle node on right) has 2 relationships connected to it. We can return that node by either querying the nodes that has the property "B" or propery "C".
Is it possible to return that node with property "F" only if both the nodes are connected to it(the nodes that has the property "B" and propery "C") are queried?
When querying patterns, you want nodes only to be returned, if all of their ingoing relationships (relationships to the node) have been queried? The number of ingoing relationships might vary. Only if all of them are part of the pattern, your query will return the node.
I made a generalized version of the query above.
If you have control over the queries that go to the database, you can wrap your query in the following way.
This feels very hacky and I don't like it.
with count(r) as countrelationships,targetnode
// Put all the connected nodes you want to query here
where sourcenode.name="B" or sourcenode.name="C"
with count(*) as querycount,countrelationships,targetnode
No Rows will be returned if targetnode has more ingoing relationships than connected nodes queried.
Still, if users have DB-accounts, they can use queries as they wish. You'll have to wrap their queries like this in another layer of your software, in your application.
I think what you want to do is not supported by Neo4J.