Neo4j: Convenient Backend for Network Navigation, Editing and Search - neo4j

I'm a sociology PhD student and I'm trying to use Neo4j to manually build the social network of the political elite in a given country. I say "manually" because I will need to input all the data manually as I come across it in my readings.
For this I would need an interface that allows me to navigate the network, as well as search and edit my database conveniently. Crucially, that would include the capacity to search for node and relationship attributes, and edit the database in real time when in graph visualization mode.
It looks like the default Neo4j admin dashboard only allows you to search by node and relationship numbers, and doesn't allow the editing of the database when in graph visualization mode. Am I right? If so, is there an alternative interface that will allow me to do this? I looked into Neoeclipse but I'm not sure it's the right tool for the job. (I also haven't been able to properly load my database on it)
Thanks in advance for the help!
JB

Which version are you looking at? Neo4j 2.0 is a really convenient UI for what you want to do.
You can easily find by property:
MATCH (user:User {name="Peter"}) return user
or
MATCH (user:User {name="Peter"})-[:KNOWS]->(other) return user,other
And you can store these queries as favorites so you don't have to type them more than once.
And you can explore the graph by double clicking nodes.
For the visualization, if you click once on each node you can see its properties and also configure which property is shown in the graph.

Related

How do I share Neo4j graphs with Non-technical users?

Neo4j visualizations are fantastic but when I share it with non technical users they get confused. Is there any way to have a version of the portal with just the nodes view, along with some prebuild cypher queries they can click, or maybe even parameterized queries where they don't see the cypher.
I feel like Neo4j has a very powerful user interface but it's only accessible to developers. I'm sure they can click the cypher queries in the star'ed queries section but I'd like to hide them from any code as it may confuse them.
Create a new user with only the READ privilege
Then, set up custom "cards" available via a :play http://yourdomain/yourcards.html with the content and queries you'll write for your users
For custom browser guides please have a look at the developer page, this should help you create slides for you users that guide them through your data.
http://localhost:8000/developer/resources/guide-create-neo4j-browser-guide/

Neo4J Multi Tenancy and Role Based Access to Nodes

I am trying to define a user management and permissions model for Neo4j. I have a web application (Angular 2) that connects to Neo4j via an API (KOANEO4J). Neo4j is the only database or persistent storage that the application uses. Through the application a user can add/edit/delete content which uses the API to carry out these instructions in Neo4j by running Cypher Statements. Up to now I have not worried about supporting multiple users but as a next step I am starting to think about this.
The product will be used by multiple different companies and each company will have multiple users so I need some way to support this. The model I am considering in Neo4J is as follows:
An "Orgaization" is represented by a node and it can have 1 or more "Organization Catalogs". All of the nodes belonging to that catalog will be children of one of the "Organization Catalogs".
Each user will also be represented by a node in the database. They will belong to an Organisation. They will have certain access permissions on an Organization Catalog identified by a an edge.
I am looking for some advice on whether or not this is an appropriate model to follow or if there are any examples or documents that describe how to achieve this in Neo4j.
If I do implement this model then would it be better to model the permissions as seperate nodes so a user is connected to a permission node (e.g. Read Only Access) that is then connected to the Organization Catalog.
Any suggestions on how I would actually get the API to work with this type of model. I'm sure I can pass the User Id to Neo4j as part of each query and then filter the results to show only nodes the user has access to but this doesn't seem like a very elegant solution - it also means that all of the security would be dependant on carefully written Cypher queries that don't leak data that a user isnt supposed to access.
Thanks a lot
I am looking for some advice on whether or not this is an appropriate
model to follow or if there are any examples or documents that
describe how to achieve this in Neo4j.
The answer for this question is: it depends. Remember that when modelling a graph database you should consider the queries that are asked to the database. If this model fits the queries that you are asking to the database then this model is appropriated, otherwise, not. Take a look in the Chapter 5 (Graphs in the Real World) of the book Graph Databases (by Ian Robison, Jim Webber and Emil Eifrem. Available for download here). This chapter shows the modelling process of an Authorization and Access Control system in Neo4j. Can be enlightening and helpful to you.
If I do implement this model then would it be better to model the
permissions as seperate nodes so a user is connected to a permission
node (e.g. Read Only Access) that is then connected to the
Organization Catalog.
Again, it depends. Do it if the Permission entity has connection to others entities of your application besides an User and an Organization Catalog. Otherwise I believe that your permission can be modeled as a relationship between an user and an organization catalog.
Any suggestions on how I would actually get the API to work with this
type of model. I'm sure I can pass the User Id to Neo4j as part of
each query and then filter the results to show only nodes the user has
access to but this doesn't seem like a very elegant solution - it also
means that all of the security would be dependant on carefully written
Cypher queries that don't leak data that a user isnt supposed to
access.
Maybe is a good idea add another layer of software between your AngularJS client app and the Neo4j database. This way in this new layer of software (a Node.js application, for example) you can implement a access control system, then verifiy if the authenticated user can access the resource that is being requested.

Display only a specific relationship type in a Neo4j Browser query

I have a simple Neo4j graph database that I created while trying to model something for a new application. When I run the following query, I get the nodes that I am expecting, but I also get more relationships than I bargained for:
MATCH (o:Office)-[r:REPORTS_VARIABLE_TO]->()
RETURN o,r
This is what the results look like:
Since I specifically requested things that match with [:REPORTS_VARIABLE_TO] I expected to see only that relationship in the results. What I see, though, is all relationships that exist between any matching nodes (as you can see on the bottom of the image).
Is there a way to filter out those relationships that are not of the type I'm looking for?
For the newest versions (e.g 3.2, 3.3) the "auto-complete" toggle has been moved to the browser settings and its new name is "Connected all results". If it is checked, it connects nodes with all of their relationships. Otherwise, you only see relationships which meet the filtering criteria.
So, as Nicole White was kind enough to point out, the answer is to turn off the "auto-complete" toggle in the Neo4j visualizer (bottom right hand corner, outlined in red in the image below).
This causes the app to no longer display all of the relationships between displayed/selected nodes and to only show the relationships and nodes named in the query, as demonstrated below:
I'm pretty sure this is just a feature of the visualisation in the back-end that will display all relationships between any two nodes on the screen (note that it also displays the destination nodes even though you haven't asked for them in the return statement).
If you look at the raw query results you'll only get the relationship types you specify.
So, to put it simply: your query is perfectly valid and correct; this is just the Neo4j admin tools playing a trick on you.
Using Neo4j Desktop 1.3.8 and the Neo4j Browser, you need to uncheck the setting "Connect result nodes".
Open the Neo4j Browser for your database.
Click "Browser Settings" gear icon.
Scroll to bottom and uncheck "Connect result nodes"
Re-run your query in the browser

Linking external resources to Neo4j nodes

I can give the url as a property to a node in Neo4j. Is there a way through which on click of the property/node,Neo4j can open that URL?
Or is there any way through which I can link external resources to Neo4j nodes?
If you store a URI in a node, it's up to your app to determine what to do with it (such as following the link). Neo4j is not going to reach out to external resources for you.
Not sure exactly what you mean by
link external resources to Neo4j nodes
If you're implying that something external to Neo4j can have a link (pointer, URI, etc.) to a Neo4j node, then no: This is again the domain of your app to provide some type of linkage (via api or any other technique). Just like you cannot have a direct link into a row of a relational database. Not only are you exposing data directly, this would imply bypassing any business rules, security, etc.
It might be too late to answer but still I would like to mention it here.
Simplest solution would be to just add your url/hyperlink as a property to the node. Neo4j Browser, Bloom, Graph X(Kineviz) support hyperlinks and redirect you to the corresponding website when you click on the url/hyperlink.
Example: I have a node called studies. I am adding hyperlink based on the id. Note that the hyperlink will be different for nodes with different nct_id.
CQL :
match( n:studies)
set n.link= case when n.nct_id =null then null else ('https://clinicaltrials.gov/ct2/show/'+n.nct_id) end

Deploying Neo4j database

so I developed a small Neo4j database with the aim of providing users with path-related information (shortest path from A to B and properties of individual sections of the path). My programming skills are very basic, but I want to make the database very user-friendly.
Basically, I would like to have a screen where users can choose start location and end location from dropdown lists, click a button, and the results (shortest path, distance of the path, properties of the path segments) will appear. For example, if this database had been made in MS Access, I would have made a form, where users could choose the locations, then click a control button which would have executed a query and produced results on a nice report.
Please note that all the nodes, relationships and queries are already in place. All I am looking for are some tips regarding the most user-friendly way of making the information accessible to the users.
Currently, all I can do is make the users install neo4j, run neo4j every time they need it, open the browser, run the cypher script and then edit the cypher script (write down strings as locations) and then execute the query. This makes it rather impractical for users and also I am worried that some user might corrupt the data,
I'd suggest making a web application using a web framework like Rails, especially if you're new to programming. You can use the neo4j gem for that to connect to your database and create models to access the data in a friendly way:
https://github.com/neo4jrb/neo4j
I'm one of the maintainers of that gem, so feel free to contact us if you have any questions:
neo4jrb#googlegroups.com
http://twitter.com/neo4jrb
Also, you might be interested in look at my newest project called meta model:
https://github.com/neo4jrb/meta_model
It's a Rails app that lets you define via the web app UI your database model (or at least part of it) and then browse/edit the objects via the web app. It's still very much preliminary, but I'd like to be able to things like what you're talking about (letting users examing data and the relationships between them in a user friendly way)
I general you would write an tiny (web/desktop/forms-)application that contains the form, takes the form values and issues the cypher requests with the form values as parameters.
The results can then be rendered as a table or chart or whatever.
You could even run this from Excel or Access with a Macro (using the Neo4j http endpoint).
Depending on your programming skills (which programming language can you write in) it can be anything. There is also a Neo4j .Net client (see http://neo4j.com/developer/dotnet).
And it's author Tatham Oddie showed a while ago how to do that with Excel

Resources