Book Image

Learning Neo4j 3.x - Second Edition

By : Jerome Baton
Book Image

Learning Neo4j 3.x - Second Edition

By: Jerome Baton

Overview of this book

Neo4j is a graph database that allows traversing huge amounts of data with ease. This book aims at quickly getting you started with the popular graph database Neo4j. Starting with a brief introduction to graph theory, this book will show you the advantages of using graph databases along with data modeling techniques for graph databases. You'll gain practical hands-on experience with commonly used and lesser known features for updating graph store with Neo4j's Cypher query language. Furthermore, you'll also learn to create awesome procedures using APOC and extend Neo4j's functionality, enabling integration, algorithmic analysis, and other advanced spatial operation capabilities on data. Through the course of the book you will come across implementation examples on the latest updates in Neo4j, such as in-graph indexes, scaling, performance improvements, visualization, data refactoring techniques, security enhancements, and much more. By the end of the book, you'll have gained the skills to design and implement modern spatial applications, from graphing data to unraveling business capabilities with the help of real-world use cases.
Table of Contents (24 chapters)
Title Page
Credits
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Indexes


In Neo4j, indexes are used to find the starting points of the queries. You can count on them. Indexes are automatically created on properties that have a constraint. Otherwise, you can create an index with a query like the following:

CREATE INDEX ON :LabelName(propertyName)

However, refrain from creating an index for every property of each label as they need to be maintained by the server when data is inserted. It is taken care of  here, but there is no magic.

The command to get the list of indexes in use in your graph is as follows:

CALL db.indexes

Force index usage

You may force the use of an index by specifying it in your query, as follows:

MATCH (t:Tower {name: ""})
 USING INDEX t:Tower(name)
 RETURN ...

Force label usage

You may also force the planner to start by evaluating nodes for a label instead of an index. This is particularly useful if you are querying for nodes having two labels and you know that one of the labels is more restrictive than the other. In this example, we could...