Chapter 1. A case for a Neo4j database
Listing 1.1. SQL script defining tables for social network data
Listing 1.2. Neo4j Traversal API code for finding all friends at depth 2
Chapter 3. Starting development with Neo4j
Listing 3.1. Creating a single user node in Neo4j (Java 6/Neo4j 1.9.X style)
Listing 3.2. Creating single user node in Neo4j (Java 7/Neo4j 2.0.X style)
Listing 3.3. Creating multiple nodes in a single transaction
Listing 3.4. Creating relationships between nodes using the Neo4j Core Java API
Listing 3.5. Adding name property to user nodes
Listing 3.6. Adding different property types to nodes
Listing 3.7. Creating movie nodes using Neo4j Core Java API
Listing 3.8. Adding a type property to determine node types
Listing 3.9. Creating relationships with properties
Chapter 4. The power of traversals
Listing 4.1. Filtering movies by iterating through all relationships from the node
Listing 4.2. Filtering movies using the Neo4j Core Java API filtering capabilities
Listing 4.3. Finding movies that have been seen by John’s friends
Listing 4.4. Finding movies that have been seen by John’s friends but not by John
Listing 4.5. Using iterables to lower Java heap memory consumption
Listing 4.6. Using the Neo4j Traversal API to find movies seen by friends
Listing 4.7. Custom evaluator to exclude movies that the user has seen
Listing 4.8. Improved traversal definition with a custom evaluator
Chapter 5. Indexing the data
Listing 5.1. Creating an index entry for a node using Neo4j API
Listing 5.2. Finding a single user by index lookup using the email property
Listing 5.3. Iterating through multiple results of an index lookup operation
Listing 5.4. Updating the index using sequential remove and add operations
Chapter 6. Cypher: Neo4j query language
Listing 6.1. Traversing the graph using Java API to find all movies the user has seen
Chapter 7. Transactions
Listing 7.1. Attempting to update without a transaction
Listing 7.2. Attempting to update with a transaction
Listing 7.3. A really big transaction can run out of memory
Listing 7.4. Reading the same thing twice without a transaction
Listing 7.5. Reading the same thing twice with increased isolation
Listing 7.6. Acquiring write locks explicitly
Listing 7.7. Configuring Spring transaction manager
Chapter 8. Traversals in depth
Listing 8.1. Walking the entire graph depth-first using the Neo4j Traversal API
Listing 8.2. Breadth-first traversal using the Neo4j Traversal API
Listing 8.3. Finding all movies John’s friends and colleagues like
Listing 8.4. Expanding relationships in the order of relationship types
Listing 8.5. Expanding relationships based on distance from the starting node
Listing 8.6. Finding all movies John’s friends like using a custom expander
Listing 8.7. Finding Jane’s direct connections who can introduce her to Ben
Listing 8.8. Making connections using NODE_PATH uniqueness
Listing 8.9. Bidirectional traversal that finds paths between two users in a social network
Chapter 9. Spring Data Neo4j
Listing 9.1. Initial POJO modeling attempt
Listing 9.2. SDN annotated domain model
Listing 9.3. The Viewing class as a relationship entity
Listing 9.4. User and Movie node entity snippets
Listing 9.5. User and Movie node entity snippets
Listing 9.6. XML-based Spring configuration
Listing 9.7. A basic Neo4jTemplate example
Listing 9.8. A Neo4jTemplate example with full Spring integration
Listing 9.9. Loading and saving data via the UserRepository
Listing 9.10. Loading and saving
Listing 9.11. Implications for lazy loading
Listing 9.12. Active record persistence with implicit transaction
Chapter 10. Neo4j: embedded versus server mode
Listing 10.1. Embedded Neo4j dependencies
Listing 10.2. Dependency tree of core Neo4j embedded library
Listing 10.3. Starting and stopping an embedded graph database
Listing 10.4. HTTP service root request and response
Listing 10.5. HTTP request and response for getting info about Adam via his userId
Listing 10.6. HTTP request and response for all of Adam’s relationships
Listing 10.7. Using Cypher via REST API to get Adam’s info, including all relationships
Listing 10.8. Java REST client using the java-rest-binding library
Listing 10.9. Code used for embedded performance test comparison
Listing 10.10. Code used for server performance test (RAW API) comparison
Listing 10.11. Cypher REST request
Listing 10.12. Cypher REST response
Listing 10.13. ServerPlugin class
Listing 10.14. Extension snippet of HTTP response for getting info on Adam node
Appendix C. Setting up your project to use SDN
Listing C.1. Maven dependencies required for the simple mapping mode
Listing C.2. Maven dependencies required for the advanced mapping mode
Listing C.3. AspectJ build configuration for the advanced mapping mode
18.222.196.175