Monthly Archives: June 2013

Indexing in Neo4j

By default, Neo4j uses Lucene as its index implementation. So anyone planning to use Neo4j indexing feature, should learn the basics of inverted index and Lucene. Below tutorials are a good start

  1. Inverted Index
  2. Creating a simple inverted index
  3. How to implement search engine
  4. Lucene: Getting started

You have two options of using indexes in Neo4j

Auto-indexing

Pros

  1. If you enable this, then there will be only two indexes created; 1 for the Nodes and another one for the Relationships.
  2. Updates to the Nodes or Relationships are automatically handled by the Neo4j

Cons

  1. Tow large indexes for your entire db instance. Some use-case require finer level control.

Custom indexing

Pros

  1. Control WHAT you want to index. You can choose to index only few types of your nodes and relationships and also only few properties of those.
  2. Control WHERE you want to index. You can have separate indexes for each types of nodes/relationships. For e.g. in a movie related db, you can have users indexed in a “users” index and movies indexed in a “movies” index.
  3. Might result in less space and might be more performant.

Cons

  1. You are responsible for making sure to cascade the insert, delete and modify operations to the index as well.
Advertisements
Tagged , ,