in my dataset, i have relationship between nodes. the relationship is named as sentiment: it has either positive or negative. when i asked the neo4j to return the all the positive nodes, the result in text would return with positive paths, but when i looked at the neo4j graphs, i still see the relationship in between the nodes contains both positive and negative. i noticed that some nodes are reduced, but the path relationship still display negative. i wonder how would i do it, so that the neo4j plots will only display positive path between the nodes? or is there some setting that i miss? below is the cypher command i use:
MATCH path = (source:Node)-[rel:RELATIONSHIP_TYPE]->(target:Node)
WHERE rel.sentiment = 'positive'
RETURN path
Neo4j will expand all paths between node labels where the filter is met.
For example if your source node is a Customer the target is Product and the relationship is RATED. If a Customer has positive and negative RATED relationships to Product nodes it will return all the paths has because the condition has been met.
Returning a table of data will filter the data as youre expecting
MATCH (source:Node)-[rel:RELATIONSHIP_TYPE]->(target:Node)
WHERE rel.sentiment = 'positive'
RETURN source.property, rel.sentiment, target.property
You can also filter based on all relationships, using something like this:
MATCH path = (source:Node)-[rel:RELATIONSHIP_TYPE*]->(target:Node)
WHERE all(r IN rel WHERE r.sentiment='positive')
RETURN path
You find you get more feedback for questions like this in the Cypher category
Neo4j browser by default will display your results in graph mode with all the relationships between the nodes, not just the ones you queried for. This is why the text view was correct, but the graph view had more relationships. There is a setting to disable this.