Skip to content. | Skip to navigation

Personal tools


You are here: Home / Members / jhb / First steps with neo4j

First steps with neo4j

by Jörg Baach last modified Jul 15, 2013 05:09 PM
I was finally pointed to neo4j, a graph database. First notes and observations.



The normal REST endpoint only has transactions in the form of batches. This means that either all or none of the actions in a batch get applied to the database. This is great when the database is used standalone, and the only source of problems are the actions in the batch. For integration into a larger framework, e.g. plone, this isn't enough. An error can happen after the batch successfully was applied to the database, e.g. in some event handler that gets called later on.

For this a transactional HTTP endpoint exists. This only supports cypher queries though. There doesn't seem to be support in cypher for write actions on nodes in legacy indexes. This means effectively means that there is no (uncomplex) way of using legacy indexes in transactions.

The only way out seem to be auto_indexes (for fulltext) and Label indexes (Schema). The first doesn't need special write actions from cyphter


Labels and Indexing

Autoindexing can be activated in the The names of the indexes are fixed, node_auto_index and relationship_auto_index. The indexed attributes need to be set there as well.

Using the REST api one can create arbitary indexes, which can also be fulltext indexes. Existing indexes will be overwritten. Overwriting node_auto_index is possible, so that the auto index can be turned into a fulltext index.

'Normal' (a.k.a legacy) indexes need to have the objects added and removed manually. This can be done using the standard REST api, but not using cypher. As the transactional REST endpoint only supports cypher, this means not adding of objects during a transaction.

One can assign labels.

CREATE thing:Label
MATCH thing where'thing' set thing :Label        #set one label
MATCH thing where'thing' set thing :Label:Label2 #set two labels
MATCH thing where'thing' set thing :Label3       #to add another label

These labels get automatically indexed. One can also set properties to be labeled within these label indexes:

create index on :Label(name) #sets attribute name to be indexed

These label property indexes get automatically indexed as well.

Filed under:
Add comment

You can add a comment by filling out the form below. Plain text formatting.

Question: What is 42 minus 19?
Your answer: