1
votes

TL,DR: I need a query which gives me all nodes/relationships which contain a certain value (in my case a string, so much I know), without knowing which property(key) contains the string. I am using neo4j(latest version), meteor (latest version) and the meteor neo4j driver, which is recommended on the neo4j website for meteor.

Currently I am working (as part of my bachelor thesis) on a tool to visualize the output of any Cypher query on any database, regardless of the database contents.

So far I've managed to correctly display nodes/relationships which are coming out. My problem now is to visualize (get nodes and relationships to feed into my frontend) textual queries like (taken from the neo4j movie database, which I am using for development)

MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors)
RETURN coActors.name 

This kind of queries only returns an array of strings and not whole nodes or relationships. I now need some way (preferably a Cypher query) to get all nodes which contain for example the string "Audrey Tatou".

The problem I've now run into is that I didn't find a way to write a query which doesn't need something like

MATCH n
WHERE Person.name = "some name"

Since I don't know anything about the contents of the database I cannot use

WHERE propertyName = "propertyValue"

since I only know the value but not the name of the property.

3
You can just return the coActors instead of the property.Michael Hunger
What does "visualize" mean in this context? I can picture visualized nodes and relationships but a visualized string is.. unclear. Do you mean to handle any returned nodes/relationships and any subset of their properties, or are you really wanting to visualized any returned data? (How about WITH "foo" as bar RETURN COUNT(bar)? how do you visualize 1?)jjaderberg
Visualising strings means, that I want to get the node/relationship which contains that string in order to show it in my frontend. An example: I get an array (of strings) with 10 names of actors and I want to show the 10 nodes and the relationships between them (already have a setup for finding them) which belong to these actors.Felix Huber

3 Answers

1
votes

The only solution here will be to get every nodes with your label and check properties and values using reflection on client side.

Using cypher, the solution would be to get all properties and their values and parse their values using a foreach loop. Maybe you can do this, but I'm really not sure, it's a recent feature but you can still give a try.

Here is what I found for the cypher solution: How can I return all properties for a node using Cypher?

0
votes

So, you have query that returns array of string.

In fact - you can receive almost anything as result. Cypher is capable to return just bare strings, that are not related to anything.

Long story short - you can't vizualize this data, because of this data nature. Best you can do is to represent them as table (or similar), like Neo4j browser do this.


But, there is (probably) solution for you. Neo4j has feature called Legacy indexing. And there you can find full text indexes. Maybe this can help you.

0
votes

You can just use a driver that returns nodes and rels, or if you do the queries manually add resultDataContents entry

{statements:[{statement:"MATCH ..","resultDataContents",["graph"]}]}

to your payload and you get nodes and relationships back.