Database Reference
In-Depth Information
Chapter 5. Indexing the data
This chapter covers
• Creating and maintaining manual indexes
• Using schema indexing and auto-indexing
• Explore trade-offs when creating an indexing strategy
In the previous chapter you saw how easy it is to move between nodes in the Neo4j graph
by traversing relationships. Moving between nodes allows you to quickly and easily find
connected nodes, such as a person's friends and the movies they like. Neo4j is optimized to
make graph traversal fast, but reducing the number of nodes that needs to be traversed by
knowing where to start is important, and it becomes increasingly so as the size of the data
set increases.
To determine where to start in the graph, Neo4j uses indexing . An index in a relational data-
baseprovidestheabilitytoquicklyandeasilyfindrowsinatablebythevaluesofparticular
columns. Similarly, Neo4j indexing makes it easy to find nodes or relationships with partic-
ular property values. Unlike a relational database, Neo4j requires your application code to
create and maintain index entries.
Because theapplication codetakesontheresponsibility forindexing,youneedtogivecare-
ful thought to your indexing strategy. Poor decisions about indexing can lead to poor per-
formance or excessive disk use. In this chapter we'll show you how to create, maintain, and
useindexes withNeo4j.We'll thenexplore whyyoushouldindexanddiscuss theinevitable
trade-offs you'll need to make when creating an indexing strategy.
Before we start talking about the trade-offs, let's look at how to create index entries.
5.1. Creating the index entry
The most commonly used option when working with an index is explicitly creating the in-
dex, then adding entries as nodes are created. Each index entry typically identifies a node or
relationship property value. The index entry contains references to one or more nodes hav-
ing a particular value for the property you're indexing on.
Search WWH ::




Custom Search