Database Reference
In-Depth Information
Whathappenswhenauserwantstoupdatetheiremailaddress?Wealreadymentionedthat
all available index operations are defined on the Index<Node> interface:
Index<Node> userIndex = indexManager.forNodes("users");
The first thing you'll probably notice when looking at the Index<Node> interface is that
there are no update methods, and no way of modifying an existing index entry once you
have looked it up. The solution is quite simple: “remove then add” equals “update” when
dealing with Neo4j indexes. The following listing shows how this can be done using the
Neo4j Core Java API.
Listing 5.4. Updating the index using sequential remove and add operations
Indexing relationships
You've seen how to create index entries that allow you to quickly look up nodes in the
graph, but it's also possible to index the relationships between nodes. This is much like in-
dexing nodes, but you use relationship properties as index keys.
In our experience, it's less common for relationship indexes to be good solutions. We're
not saying that relationship indexing is a poor practice, but if you find yourself adding lots
of relationship indexes, it's worth asking why.
Usually a graph will represent entities of some form as nodes, such as people, movies, and
cities. The relationships then represent the relationships between those entities. The ques-
tions you then usually ask are about who these entities are connected to. Who likes the
movie, who is friends with a specific person, or what transport routes leave from a city.
Search WWH ::




Custom Search