Database Reference
In-Depth Information
It's not impossible to think of questions that might be answered by a relationship index,
however. If you chose to represent the star ratings in the movie database with different re-
lationships for different ratings, indexing the relationship would allow you to quickly find
all the five-star reviews.
You can read more about relationship indexing in the Neo4j Manual: http://docs.neo4j.org/
chunked/stable/indexing-relationships.html .
Later inthischapter we'lltakeamoredetailed lookatthetrade-offsassociated withindex-
ing, but first we'll complete our tour of the indexing options by taking a look at auto-in-
dexing.
5.5. Automatic indexing
So far in this chapter, we've focused on manually creating and maintaining index entries.
If you're coming from an RDBMS world, you may wonder why the database can't do this
work for you; after all, in the RDBMS world, you'd expect to declare which columns on a
table youwanted indexed andtohave the RDBMS then maintain the contents ofthat index
as rows were inserted, updated, and deleted.
There are two ways that you can have Neo4j maintain indexes automatically—schema in-
dexing and auto-indexing. Let's take a look at schema indexing first.
5.5.1. Schema indexing
Inversion2.0,Neo4jintroducedtheconceptof schema indexing. Conceptually,thisissim-
ilar to the traditional index-handling approaches used by relational databases.
Schema indexing works closely with the concept of node labels, which we introduced in
chapter 3 . Eachschemaindexisspecifictoalabelandasetofproperties.Forexample,you
candefineanindexforusersontheir name property,oranindexformoviesonthe title
and production year properties. All you have to do is to define the index, and thereafter,
Neo4j will take responsibility for maintaining it. This means that when you create a node
with a label and a property that matches one or more indexes, all indexes will be updated
Search WWH ::




Custom Search