100% found this document useful (4 votes)
23 views

Building Web Applications with Python and Neo4j 1st Edition Sumit Gupta instant download

The document provides information about the book 'Building Web Applications with Python and Neo4j' by Sumit Gupta, which focuses on developing Python-based web applications using Neo4j and frameworks like Flask and Django. It includes details on the author's background, the book's content structure, and various chapters covering topics such as querying graphs, using Python with Neo4j, and deploying applications. Additionally, it offers links to other related eBooks and resources for further exploration.

Uploaded by

ladakroutt4o
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
23 views

Building Web Applications with Python and Neo4j 1st Edition Sumit Gupta instant download

The document provides information about the book 'Building Web Applications with Python and Neo4j' by Sumit Gupta, which focuses on developing Python-based web applications using Neo4j and frameworks like Flask and Django. It includes details on the author's background, the book's content structure, and various chapters covering topics such as querying graphs, using Python with Neo4j, and deploying applications. Additionally, it offers links to other related eBooks and resources for further exploration.

Uploaded by

ladakroutt4o
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Building Web Applications with Python and Neo4j

1st Edition Sumit Gupta download

https://ebookname.com/product/building-web-applications-with-
python-and-neo4j-1st-edition-sumit-gupta/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Building Web Apps with WordPress 1st Edition Brian


Messenlehner

https://ebookname.com/product/building-web-apps-with-
wordpress-1st-edition-brian-messenlehner/

Building Web Services with Microsoft Azure 1st Edition


Belotserkovskiy

https://ebookname.com/product/building-web-services-with-
microsoft-azure-1st-edition-belotserkovskiy/

Homogeneous Catalysis Mechanisms and Industrial


Applications 2nd Edition Sumit Bhaduri

https://ebookname.com/product/homogeneous-catalysis-mechanisms-
and-industrial-applications-2nd-edition-sumit-bhaduri/

Nutrition Immunity and Infection First Edition Prakash


Shetty

https://ebookname.com/product/nutrition-immunity-and-infection-
first-edition-prakash-shetty/
Design for Motion Fundamentals and Techniques of Motion
Design Austin Shaw

https://ebookname.com/product/design-for-motion-fundamentals-and-
techniques-of-motion-design-austin-shaw/

The Encyclopedia of Skin and Skin Disorders Facts on


File Library of Health and Living 3rd Edition Carol
Turkington

https://ebookname.com/product/the-encyclopedia-of-skin-and-skin-
disorders-facts-on-file-library-of-health-and-living-3rd-edition-
carol-turkington/

Tables of Knowledge Descartes in Vermeer s Studio


Harriet Stone

https://ebookname.com/product/tables-of-knowledge-descartes-in-
vermeer-s-studio-harriet-stone/

Gilles Deleuze 1st Edition Claire Colebrook

https://ebookname.com/product/gilles-deleuze-1st-edition-claire-
colebrook/

Teaching Intercultural Rhetoric and Technical


Communication Theories Curriculum Pedagogies and
Practice 1st Edition Barry Thatcher

https://ebookname.com/product/teaching-intercultural-rhetoric-
and-technical-communication-theories-curriculum-pedagogies-and-
practice-1st-edition-barry-thatcher/
Pick Your Yoga Practice Exploring and Understanding
Different Styles of Yoga 1st Edition Meagan Mccrary

https://ebookname.com/product/pick-your-yoga-practice-exploring-
and-understanding-different-styles-of-yoga-1st-edition-meagan-
mccrary/
Building Web Applications
with Python and Neo4j

Develop exciting real-world Python-based


web applications with Neo4j using frameworks
such as Flask, Py2neo, and Django

Sumit Gupta

BIRMINGHAM - MUMBAI
Building Web Applications with Python and Neo4j

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: July 2015

Production reference: 1100715

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78398-398-8

www.packtpub.com
Credits

Author Copy Editors


Sumit Gupta Vikrant Phadke
Alpha Singh
Reviewers
Adarsh Deshratnam Project Coordinator
Gianluca Tiepolo Izzat Contractor
Tsanyo Tsanev
Manuel Vives Proofreader
Safis Editing

Commissioning Editor
Kunal Parikh Indexer
Rekha Nair

Acquisition Editor
Larissa Pinto Production Coordinator
Aparna Bhagat

Content Development Editor


Anish Sukumaran Cover Work
Aparna Bhagat

Technical Editors
Novina Kewalramani
Ryan Kochery
Manal Pednekar
About the Author

Sumit Gupta is a seasoned professional, innovator, and technology evangelist,


with over 100 months of experience in architecting, managing, and delivering
enterprise solutions that revolve around a variety of business domains, such as
hospitality, healthcare, risk management, insurance, and so on. He is passionate
about technology, with over 14 years of hands-on experience in the software
industry. Sumit has been using big data and cloud technologies for the past
4 to 5 years to solve complex business problems.

He is also the author of Neo4j Essentials (http://neo4j.com/books/neo4j-


essentials/).

I want to acknowledge and express my gratitude to everyone


who supported me in authoring this book. I am thankful for their
inspiring guidance and valuable, constructive, and friendly advice.
About the Reviewers

Adarsh Deshratnam is a senior consultant (big data and cloud) whose focus is
on designing, developing, and deploying Hadoop solutions for many MNCs. In
this position, he has worked with customers to build several Hadoop applications
with multiple database technologies, providing a unique perspective on moving
customers beyond batch processing. An avid technologist, he focuses on technological
innovations. Since 2006, he has been working full time and part time with big data and
multiple database technologies. Adarsh completed his engineering at Staffordshire
University with a computing major.

I would like to thank Packt Publishing for giving me the wonderful


opportunity to review a book on one of the quickly evolving graph
databases (Neo4j).

Gianluca Tiepolo has been programming since Windows 3.11 was around.
As a cofounder of Sixth Sense Solutions, a start-up that is a global leader in retail
solutions, he has worked with some of the world's biggest brands to deliver engaging,
interactive experiences to their customers. He specializes in high-performance
implementations of database services and computer vision. Currently, he's deeply
involved in the open source community and has a lot of interest in big data.

I want to thank my wonderful wife, Adele; my awesome teammates;


and my friend Marco for their support and inspiration.
Tsanyo Tsanev is a senior web developer at Dressler LLC in New York, USA.
From the whiteboard to production, he has experience in building a variety of web
applications. He began experimenting with Neo4j for the social networking website
SongSilo and has since found many other uses for it. Tsanyo's passion is coding;
he does it both for a living and as a hobby.

Manuel Vives is a software engineer, who focuses on Python and C++.


He specializes in backend parts of distributed software and NoSQL databases.
He used to work in France for a company that specializes in cybersecurity and
training, and he now works in Canada.
www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface v
Chapter 1: Your First Query with Neo4j 1
Thinking in graphs for SQL developers 2
Comparing SQL and Cypher 3
Evolving graph structures from SQL models 5
Licensing and configuring – Neo4j 8
Licensing – Community Edition 8
Licensing – Enterprise Edition 8
Installing Neo4J Community Edition on Linux/Unix 9
Installing as a Linux tar / standalone application 10
Installing as a Linux service 11
Installing Neo4j Enterprise Edition on Unix/Linux 12
Using the Neo4j shell 14
Introducing the Neo4j REST interface 16
Authorization and authentication 16
CRUD operations 17
Running queries from the Neo4j browser 20
Summary 21
Chapter 2: Querying the Graph with Cypher 23
Basic anatomy of a Cypher query 24
Brief details of Cypher 24
Cypher execution phases 25
Parsing, validating, and generating the execution plan 25
Locating the initial node(s) 26
Selecting and traversing the relationships 26
Changing and/or returning the values 26
The structure of Cypher 26
The read operations 27

[i]
Table of Contents

The create or update operations 30


The delete operation 32
Pattern and pattern matching 32
Sample dataset 32
Pattern for nodes 34
Pattern for labels 34
Pattern for relationships 34
Pattern for properties 35
Using the where clause with patterns 35
Using patterns in the where clause 36
Using general clauses with patterns 36
The order by clause 37
The limit and skip clauses 37
The WITH clause 37
The UNION and UNION ALL clauses 38
Working with nodes and relationships 39
Summary 43
Chapter 3: Mutating Graph with Cypher 45
Creating nodes and relationships 46
Working with nodes 46
Single node 46
Multiple nodes 48
Node with labels 48
Node with properties 49
Working with relationships 51
Single relationships 51
Multiple relationships 52
Relationships with properties 54
Nodes and relationships with full paths 55
Creating unique nodes and relationships 55
CREATE UNIQUE and MERGE 55
Working with constraints 56
Transforming nodes and relationships 57
Updating node properties 57
Updating a label 58
Updating relationships 58
Cypher query optimizations 58
Indexes 59
Index sampling 61
Understanding execution plans 62
Analyzing and optimizing queries 64
Summary 66

[ ii ]
Table of Contents

Chapter 4: Getting Python and Neo4j to Talk Py2neo 67


Installing and configuring py2neo 68
Prerequisites 68
Installing py2neo 69
Exploring the py2neo APIs 70
Graph 70
Authentication 71
Node 72
Relationship 75
Cypher 77
Transactions 80
Paths 81
Creating a social network with py2neo 83
Batch imports 86
Unit testing 88
Summary 91
Chapter 5: Build RESTful Service with Flask and Py2neo 93
Introducing (and installing) Flask 94
Setting up web applications with Flask and Flask-RESTful 96
Your first Flask application 96
Displaying static content 98
Displaying dynamic content 99
Your first Flask RESTful API 101
JSON processing 102
REST APIs for social network data using py2neo 104
ORM for graph databases py2neo – OGM 104
Social network application with Flask-RESTful and OGM 106
Creating object model 106
Creating REST APIs over data models 110
Summary 114
Chapter 6: Using Neo4j with Django and Neomodel 115
Installing and configuring Neomodel 116
Declaring models and properties 118
Defining nodes 118
Defining properties 119
Persisting and querying a social data model 121
Adding relationships to models 125
Running Cypher queries 129
Using Neomodel in a Django app 130
Signals in Neomodel 131
Summary 132

[ iii ]
Table of Contents

Chapter 7: Deploying Neo4j in Production 133


Neo4j logical architecture 134
Disk/filesystem 135
Record files 135
Transaction logs 137
Caches 137
Core Java API 139
Traversal framework 140
REST API 141
Neo4j physical architecture 142
High availability 142
Fault tolerance 144
Data replication and data locality 145
Advanced settings 146
Monitoring the health of the Neo4J nodes 147
Neo4j browser 148
Webadmin 148
JMX beans 149
Backup and recovery 152
Summary 153
Index 155

[ iv ]
Preface
Relational databases have been one of the most widely used and most common
forms of software systems for the storage of data since the 1970s. They are highly
structured and store data in the form of tables, that is, with rows and columns.
Structuring and storing data in the form of rows and columns has its own
advantages; for example, it is easier to understand and locate data, reduce data
redundancy by applying normalization, maintain data integrity, and much more.

But is this the best way to store any kind of data?

Let's consider an example of social networking:

Mike, John, and Claudia are friends. Claudia is married to Wilson. Mike and Wilson
work for the same company.

Here is one of the possible ways to structure this data in a relational database:

[v]
Preface

Complex, isn't it? And it can be more complex!

We should remember that relationships are evolving, and will evolve over a period
of time. There could be new relationships, or there could be changes to existing
relationships.

We can design a better structure but in any case, wouldn't that be forcibly fitting the
model into a structure?

RDBMS is good for use cases where the relationship between entities is more or less
static and does not change over a period of time. Moreover, the focus of RDBMS is
more on the entities and less on the relationships between them.

There could be many more examples where RDBMS may not be the right choice:

1. Model and store 7 billion people objects and 3 billion non-people objects to
provide an "earth view" drill-down from the planet to a sidewalk
2. Network management
3. Genealogy
4. Public transport links and road maps

Consider another way of modelling the same data:

Simple, isn't it?

Welcome to the world of Neo4j—a graph database.

[ vi ]
Preface

Although there is no single definition of graphs, here is the simplest one (http://
en.wikipedia.org/wiki/Graph_(abstract_data_type)), which helps us to
understand the theory of graphs:

A graph data structure consists of a finite (and possibly mutable) set of nodes or
vertices, together with a set of ordered pairs of these nodes (or, in some cases, a set
of unordered pairs). These pairs are known as edges or arcs. As in mathematics,
an edge (x,y) is said to point or go from x to y. The nodes may be part of the graph
structure, or may be external entities represented by integer indices or references.

Neo4j, as an open source graph database, is part of the NoSQL family, and provides
a flexible data structure, where the focus is on the relationships between the entities
rather than the entities themselves.

Its first version (1.0) was released in February 2010, and since then, it has never
stopped. It is amazing to see the pace at which Neo4J has evolved over the years. At
the time of writing this book, the stable version was 2.2.RC01, which was released in
March 2015.

If you are reading this book, then you probably already have sufficient knowledge
about graph databases and Python. You will appreciate their contribution to the
complex world of relationships.

Let's move forward and jump into the nitty-gritty of developing web applications
with Python and Neo4j.

In the subsequent chapters, we will cover the various aspects dealing with data
modelling, programming, and data analysis by means of application development
with Python and Neo4j. We will cover the concepts of working with py2neo, Django,
flask, and many more.

What this book covers


Chapter 1, Your First Query with Neo4j, details the process of the installation of Neo4j
and Python on Windows and Linux. This chapter briefly explains the function
of every tool installed together with Neo4j (shell, server, and browser). More
importantly, it introduces, and helps you get familiar with, the Neo4j browser. You
get to run the first basic Cypher query by using different methods exposed by Neo4j
(shell, Java, the browser, and REST).

[ vii ]
Preface

Chapter 2, Querying the Graph with Cypher, starts by explaining Cypher as a graph
query language for Neo4j, and then we take a deep dive into the various Cypher
constructs to perform read operations. This chapter also talks about the importance
of patterns and pattern matching, and their usage in Cypher with various real-world
and easy-to-understand examples.

Chapter 3, Mutating Graph with Cypher, starts by covering the Cypher constructs
used to perform write operations on the Neo4j database. This chapter further talks
about creating relationships between nodes and discusses the constraints required
for maintaining the integrity of data. At the end, it discuss about the performance
tuning of Cypher queries using various optimization techniques.

Chapter 4, Getting Python and Neo4j to Talk Py2neo, introduces Py2neo as a Python
framework for working with Neo4j. This chapter explores various Python APIs
exposed by Py2neo for working with Neo4j. It also talks about batch imports
and introduces a social network use case, which is created and unit tested by
using Py2neo APIs.

Chapter 5, Build RESTful Service with Flask and Py2neo, talks about building web
applications and the integration of Flask and Py2neo. This chapter starts with the
basics of Flask as a framework for exposing ReSTful APIs, and further talks about
the Py2neo extension OGM (short for Object Graph Mapper) and its integration with
Flask for performing various CRUD and search operations on the social network use
case by creating and leveraging various ReST endpoints.

Chapter 6, Using Neo4j with Django and Neomodel, starts by describing Neomodel as
an ORM for Neo4j. It discusses various high-level APIs exposed by Neomodel to
perform CRUD and search operations using Python APIs or by directly executing
Cypher queries. Finally, it talks about integration of two of the popular Python
frameworks, Django and Neomodel.

Chapter 7, Deploying Neo4j in Production, explains the logical architecture of Neo4j,


its various components, or APIs, such as filesystems, data organization and so
on. Then we move on to the physical architecture of Neo4j, where we talk about
meeting various NFRs imposed by typical enterprise deployments, such as HA,
fault tolerance, data locality, backup, and recovery. Further, this chapter talks
about various advanced Neo4j configurations and also discusses the various
ways to monitor our Neo4j deployments.

[ viii ]
Preface

What you need for this book


Readers should have programming experience in Python and some basic knowledge
or understanding of any graph or NoSQL databases.

Who this book is for


This book is aimed at competent developers who have a good knowledge and
understanding of Python that can allow efficient programming of the core elements
and applications.

If you are reading this book, then you probably already have sufficient knowledge
of Python. This book will cover data modelling, programming, and data analysis by
means of application development with Python and Neo4j. It will cover concepts
such as working with py2neo, Django, flask, and so on.

Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"We can include other contexts through the use of the include directive."

A block of code is set as follows:


MATCH (x { name: "Bradley" })--(y)-->()
WITH x
CREATE (n:Male {name:"Smith", Age:"24"})-[r:FRIEND]->(x)
returnn,r,x;

Any command-line input or output is written as follows:


pip install flask Flask-RESTful

New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "Now,
click on the star sign in the panel on the extreme left-hand side, and click on
Create a node in the provided menu."

[ ix ]
Preface

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail feedback@packtpub.com, and mention


the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.

Downloading the example code


You can download the example code files from your account at http://www.
packtpub.com for all the Packt Publishing books you have purchased. If you
purchased this book elsewhere, you can visit http://www.packtpub.com/support
and register to have the files e-mailed directly to you.

[x]
Preface

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected


pirated material.

We appreciate your help in protecting our authors and our ability to bring you
valuable content.

Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.

[ xi ]
Chapter 1

Your First Query with Neo4j


Neo4j is a graph database and has been in commercial development for over a
decade. It comes with several flavors, supporting a wide variety of use cases and
requirements imposed by start-ups, large enterprises, and Fortune 500 customers.
It is a fully transactional database; it supports Atomicity, Consistency, Isolation,
Durability (ACID) and is also well equipped to handle the complexities introduced
by various kinds of systems—web-based, online transaction processing (OLTP),
data-warehousing, analytics, and so on.

This chapter will help you to understand the paradigm, applicability, various
aspects, and characteristics of Neo4j as a graph database. It will guide you through
the installation process, starting right from downloading and running your first
Cypher query leveraging various interfaces/tools/utilities exposed by Neo4j
against your fully-working instance.

At the end of this chapter, your work environment will be fully functional, and
you will be able to write your first Cypher query to insert/fetch the data from the
Neo4j database.

This chapter will cover the following points:

• Thinking in graphs for SQL developers


• Licensing and configuring – Neo4j
• Using the Neo4j shell
• Introducing the Neo4j REST interface
• Running queries from the Neo4j browser

[1]
Your First Query with Neo4j

Thinking in graphs for SQL developers


Some might say that it is difficult for SQL developers to understand the paradigm of
graphs, but it is not entirely true. The underlying essence of data modeling does not
change. The focus is still on the entities and the relationship between these entities.
Having said that, let's discuss the pros/cons, applicability, and similarity of the
relational models and graph models.

The relational models are schema-oriented. If you know the structure of data
in advance, it is easy to ensure that data conforms to it, and at the same time, it
helps in enforcing stronger integrity. Some examples include traditional business
applications, such as flight reservations, payroll, order processing, and many more.

The graph models are occurrence-oriented—Probabilistic model. They are adaptive


and define a generic data structure that is evolving and works well with scenarios
where the schema is not known in advance. The graph model is perfectly suited to
store, manage, and extract highly-connected data.

Let's briefly discuss the disadvantages of the SQL databases, which led to the
evolution of the graph databases:

• It is difficult to develop efficient models for evolving data, such as social


networks
• The focus is more on the structure of data than the relationships
• They lack an efficient mechanism for performing recursions

All the preceding reasons were sufficient to design a different data structure, and as
a result, the graph data structures were introduced.

The objective of the graph databases was specifically to meet the disadvantages
of the SQL databases. However, Neo4j as a graph database, also leveraged the
advantages of the SQL databases wherever possible and applicable. Let's see a
few of the similarities between the SQL and graph databases:

• Highly Consistent: At any point in time, all nodes contain the same data at
the same time
• Transactional: All insert or update operations are within a transaction where
they are ACID

Having said that, it is not wrong to say that the graph databases are more or less the
next generation of relational databases.

[2]
Chapter 1

Comparing SQL and Cypher


Every database has its own query languages; for example, RDBMS leverages SQL
and conforms to SQL-92 (http://en.wikipedia.org/wiki/SQL-92). Similarly,
Neo4j also has its own query language—Cypher. The syntax of Cypher has
similarities with SQL, though it still has its own unique characteristics, which
we will discuss in the upcoming sections.

Neo4j leveraged the concept of patterns and pattern matching, and introduced a new
declarative graph query language, Cypher, for the Neo4j graph database. Patterns
and pattern matching are the essence and core of Neo4j, so let's take a moment to
understand them. We will then talk about the similarities between SQL and Cypher.

Patterns are a given sequence or occurrence of tokens in a particular format. The act
of matching patterns within a given sequence of characters or any other compatible
input form is known as pattern matching. Pattern matching should not be confused
with pattern recognition, which usually produces the exact match and does not have
any concept of partial matches.

Pattern matching is the heart of Cypher and a very important component of the
graph databases. It helps in searching and identifying a single or a group of nodes
by walking along the graph. Refer to http://en.wikipedia.org/wiki/Pattern_
matching for more information on the importance of pattern matching in graphs.
Let's move forward and talk about Cypher, and it's similarities with SQL.

Cypher is specifically designed to be a human query language, which is focused


on making things simpler for developers. Cypher is a declarative language and
implements "What to retrieve" and not "how to retrieve", which is in contrast to
the other imperative languages, such as Java and Gremlin (refer to http://gremlin.
tinkerpop.com/).

Cypher borrows much of its structure from SQL, which makes it easy to use/
understand for SQL developers. "SQL familiarity" is another objective of Cypher.

[3]
Your First Query with Neo4j

Let's refer to the following illustration, which defines the Cypher constructs and the
similarity of Cypher with SQL constructs:

The preceding diagram defines the mapping of the common SQL and Cypher
constructs. It also depicts the examples stating the usage of these constructs.

For instance, FROM is similar to MATCH or START and produces the same results.
Although the way they are used is different but the objective and concept remains
the same.

We will talk about Cypher in detail in Chapter 2, Querying the Graph with Cypher and
Chapter 3, Mutating Graph with Cypher, but without getting into the nitty-gritty and
syntactical details. The following is one more illustration that briefly describes the
similarities between the Cypher and SQL constructs:

[4]
Another Random Document on
Scribd Without Any Related Topics
Leighton and Coleridge.

It is a most unseemly and unpleasant thing, to see a man's life full


of ups and downs, one step like a Christian, and another like a
worldling; it cannot choose but both pain himself and mar the
edification of others.
The same sentiment, only with a special application to the maxims
and measures of our Cabinet and Statesmen, has been finely
expressed by a sage Poet of the preceding generation, in lines
which, no generation will find inapplicable or superannuated.
God and the World we worship both together,
Draw not our Laws to Him, but His to ours;
Untrue to both, so prosperous in neither,
The imperfect Will brings forth but barren
Flowers!
Unwise as all distracted Interests be,
Strangers to God, Fools in Humanity:
Too good for great things, and too great for good,
While still "I dare not" waits upon "I wou'd."

APHORISM XVII. CONTINUED.


The Ordinary Motive to Inconsistency.

Leighton.

What though the polite man count thy fashion a little odd and too
precise, it is because he knows nothing above that model of
goodness which he hath set himself, and therefore approves of
nothing beyond it: he knows not God, and therefore doth not discern
and esteem what is most like Him. When courtiers come down into
the country, the common home-bred people possibly think their
habit strange; but they care not for that, it is the fashion at court.
What need, then, that Christians should be so tender-foreheaded, as
to be put out of countenance because the world looks on holiness as
a singularity? It is the only fashion in the highest court, yea, of the
King of Kings himself.

APHORISM XVIII.
Superficial Reconciliations, and Self-deceit in Forgiving.

Leighton.

When, after variances, men are brought to an agreement, they


are much subject to this, rather to cover their remaining malices
with superficial verbal forgiveness, than to dislodge them, and free
the heart of them. This is a poor self-deceit. As the philosopher said
to him, who being ashamed that he was espied by him in a tavern in
the outer room, withdrew himself to the inner, he called after him,
"That is not the way out, the more you go that way, you will be the
further in!" So when hatreds are upon admonition not thrown out,
but retire inward to hide themselves, they grow deeper and stronger
than before; and those constrained semblances of reconcilement are
but a false healing, do but skin the wound over, and therefore it
usually breaks forth worse again.

APHORISM XIX.
Of the Worth and the Duties of the Preacher.

Leighton.

The stream of custom and our profession bring us to the


Preaching of the Word, and we sit out our hour under the sound; but
how few consider and prize it as the great ordinance of God for the
salvation of souls, the beginner and the sustainer of the Divine life of
grace within us! And certainly, until we have these thoughts of it,
and seek to feel it thus ourselves, although we hear it most
frequently, and let slip no occasion, yea, hear it with attention and
some present delight, yet still we miss the right use of it, and turn it
from its true end, while we take it not as that ingrafted word which
is able to save our souls (James i. 21).
Thus ought they who preach to speak the word; to endeavour
their utmost to accommodate it to this end, that sinners may be
converted, begotten again, and believers nourished and
strengthened in their spiritual life; to regard no lower end, but aim
steadily at that mark. Their hearts and tongues ought to be set on
fire with holy zeal for God and love to souls, kindled by the Holy
Ghost, that came down on the apostles in the shape of fiery
tongues.
And those that hear, should remember this as the end of their
hearing, that they may receive spiritual life and strength by the
word. For though it seems a poor despicable business, that a frail
sinful man like yourselves should speak a few words in your hearing,
yet, look upon it as the way wherein God communicates happiness
to those who believe, and works that believing unto happiness,
alters the whole frame of the soul, and makes a new creation, as it
begets it again to the inheritance of glory. Consider it thus, which is
its true notion; and then, what can be so precious?

APHORISM XX.
Leighton.

The difference is great in our natural life, in some persons


especially; that they who in infancy were so feeble, and wrapped up
as others in swaddling clothes, yet, afterwards come to excel in
wisdom and in the knowledge of sciences, or to be commanders of
great armies, or to be kings: but the distance is far greater and more
admirable, betwixt the small beginnings of grace, and our after
perfection, that fulness of knowledge that we look for, and that
crown of immortality which all they are born to who are born of God.
But as in the faces or actions of some children, characters and
presages of their after-greatness have appeared (as a singular
beauty in Moses's face, as they write of him, and as Cyrus was made
king among the shepherds' children with whom he was brought up,
&c.) so also, certainly, in these children of God, there be some
characters and evidences that they are born for Heaven by their new
birth. That holiness and meekness, that patience and faith which
shine in the actions and sufferings of the saints, are characters of
their Father's image, and show their high original, and foretell their
glory to come; such a glory as doth not only surpass the world's
thoughts, but the thoughts of the children of God themselves.
1 John iii. 2.

Comment.
On an Intermediate State, or State of Transition from Morality to
Spiritual Religion.

This Aphorism would, it may seem, have been placed more fitly in
the Chapter following. In placing it here, I have been determined by
the following convictions: 1. Every state, and consequently that
which we have described as the state of Religious Morality, which is
not progressive, is dead, or retrograde. 2. As a pledge of this
progression, or, at least, as the form in which the propulsive
tendency shows itself, there are certain Hopes, Aspirations,
Yearnings, that, with more or less of consciousness, rise and stir in
the Heart of true Morality as naturally as the sap in the full-formed
stem of a rose flows towards the bud, within which the flower is
maturing. 3. No one, whose own experience authorizes him to
confirm the truth of this statement, can have been conversant with
the volumes of religious biography, can have perused (for instance)
the lives of Cranmer, Ridley, Latimer, Wishart, Sir Thomas More,
Bernard Gilpin, Bishop Bedel, or of Egede, Swartz, and the
missionaries of the frozen world, without an occasional conviction,
that these men lived under extraordinary influences, which in each
instance and in all ages of the Christian æra bear the same
characters, and both in the accompaniments and the results
evidently refer to a common origin. And what can this be? is the
question that must needs force itself on the mind in the first
moment of reflection on a phenomenon so interesting and
apparently so anomalous. The answer is as necessarily contained in
one or the other of two assumptions. These influences are either the
Product of Delusion (insania amabilis, and the re-action of
disordered nerves), or they argue the existence of a relation to some
real agency, distinct from what is experienced or acknowledged by
the world at large, for which as not merely natural on the one hand,
and yet not assumed to be miraculous[55] on the other, we have no
apter name than spiritual. Now if neither analogy justifies nor the
moral feelings permit the former assumption, and we decide
therefore in favour of the reality of a State other and higher than the
mere Moral Man, whose Religion[56] consists in Morality, has attained
under these convictions, can the existence of a transitional state
appear other than probable? or that these very convictions, when
accompanied by correspondent dispositions and stirrings of the
heart, are among the marks and indications of such a state? And
thinking it not unlikely that among the readers of this volume, there
may be found some Individuals, whose inward state, though
disquieted by doubts and oftener still perhaps by blank misgivings,
may, nevertheless, betoken the commencement of a Transition from
a not irreligious Morality to a Spiritual Religion, with a view to their
interests I placed this Aphorism under the present head.

[55] In check of fanatical pretensions, it is expedient to confine


the term miraculous, to cases where the senses are appealed to
in proof of something that transcends, or can be a part of the
Experience derived from the senses.
[56] For let it not be forgotten, that Morality, as distinguished
from Prudence, implying (it matters not under what name,
whether of Honour, or Duty, or Conscience, still, I say, implying),
and being grounded in, an awe of the Invisible and a Confidence
therein beyond (nay, occasionally in apparent contradiction to)
the inductions of outward Experience, is essentially religious.

APHORISM XXI.
Leighton.

The most approved teachers of wisdom, in a human way, have


required of their scholars, that to the end their minds might be
capable of it, they should be purified from vice and wickedness. And
it was Socrates' custom, when any one asked him a question,
seeking to be informed by him, before he would answer them, he
asked them concerning their own qualities and course of life.

APHORISM XXII.
Knowledge not the ultimate End of Religious Pursuits.

Leighton and Coleridge.

The Hearing and Reading of the Word, under which I comprise


theological studies generally, are alike defective when pursued
without increase of Knowledge, and when pursued chiefly for
increase of Knowledge. To seek no more than a present delight, that
evanisheth with the sound of the words that die in the air, is not to
desire the Word as meat, but as music, as God tells the prophet
Ezekiel of his people, Ezek. xxxiii. 32. And lo, thou art unto them as
a very lovely song of one that hath a pleasant voice, and can play
well upon an instrument; for they hear thy words, and they do them
not. To desire the word for the increase of knowledge, although this
is necessary and commendable, and, being rightly qualified, is a part
of spiritual accretion, yet, take it as going no further, it is not the
true end of the Word. Nor is the venting of that knowledge in speech
and frequent discourse of the Word and the divine truths that are in
it; which, where it is governed with Christian prudence, is not to be
despised, but commended; yet, certainly, the highest knowledge,
and the most frequent and skilful speaking of the Word, severed
from the growth here mentioned, misses the true end of the Word.
If any one's head or tongue should grow apace, and all the rest
stand at a stay, it would certainly make him a monster; and they are
no other, who are knowing and discoursing Christians, and grow
daily in that respect, but not at all in holiness of heart, and life,
which is the proper growth of the children of God. Apposite to their
case is Epictetus's comparison of the sheep; they return not what
they eat in grass, but in wool.

APHORISM XXIII.
The sum of Church History.

Leighton.

In times of peace, the Church may dilate more, and build as it


were into breadth, but in times of trouble, it arises more in height; it
is then built upwards; as in cities where men are straitened, they
build usually higher than in the country.

APHORISM XXIV.
Worthy to be framed and hung up in the Library of every
Theological Student.
Leighton and Coleridge.

When there is a great deal of smoke, and no clear flame, it argues


much moisture in the matter, yet it witnesseth certainly that there is
fire there; and therefore dubious questioning is a much better
evidence, than that senseless deadness which most take for
believing. Men that know nothing in sciences, have no doubts. He
never truly believed, who was not made first sensible and convinced
of unbelief.
Never be afraid to doubt, if only you have the disposition to
believe, and doubt in order that you may end in believing the Truth.
I will venture to add in my own name and from my own conviction
the following:

APHORISM XXV.
He, who begins by loving Christianity better than Truth, will
proceed by loving his own Sect or Church better than Christianity,
and end in loving himself better than all.

APHORISM XXVI.
The Absence of Disputes, and a general Aversion to Religious
Controversies, no proof of True Unanimity.

Leighton and Coleridge.

The boasted peaceableness about questions of Faith too often


proceeds from a superficial temper, and not seldom from a
supercilious disdain of whatever has no marketable use or value, and
from indifference to religion itself. Toleration is a herb of
spontaneous growth in the Soil of Indifference; but the weed has
none of the virtues of the medicinal plant, reared by Humility in the
Garden of Zeal. Those, who regard religions as matters of taste, may
consistently include all religious differences in the old adage, De
gustibus non est disputandum. And many there be among these of
Gallio's temper, who care for none of these things, and who account
all questions in religion, as he did, but matter of words and names.
And by this all religions may agree together. But that were not a
natural union produced by the active heat of the spirit, but a
confusion rather, arising from the want of it; not a knitting together,
but a freezing together, as cold congregates all bodies, how
heterogeneous soever, sticks, stones, and water; but heat makes
first a separation of different things, and then unites those that are
of the same nature.
Much of our common union of minds, I fear, proceeds from no
other than the afore-mentioned causes, want of knowledge, and
want of affection to religion. You that boast you live conformably to
the appointments of the Church, and that no one hears of your
noise, we may thank the ignorance of your minds for that kind of
quietness.
The preceding extract is particularly entitled to our serious
reflections, as in a tenfold degree more applicable to the present
times than to the age in which it was written. We all know, that
Lovers are apt to take offence and wrangle on occasions that
perhaps are but trifles, and which assuredly would appear such to
those who regard Love itself as folly. These quarrels may, indeed, be
no proof of wisdom; but still, in the imperfect state of our nature the
entire absence of the same, and this too on far more serious
provocations, would excite a strong suspicion of a comparative
indifference in the parties who can love so coolly where they profess
to love so well. I shall believe our present religious tolerancy to
proceed from the abundance of our charity and good sense, when I
see proofs that we are equally cool and forbearing as litigants and
political partizans.

APHORISM XXVII.
The Influence of Worldly Views (or what are called a Man's
Prospects in Life), the Bane of the Christian Ministry.

Leighton

It is a base, poor thing for a man to seek himself; far below that
royal dignity that is here put upon Christians, and that priesthood
joined with it. Under the Law, those who were squint-eyed were
incapable of the priesthood: truly, this squinting toward our own
interest, the looking aside to that, in God's affairs especially, so
deforms the face of the soul, that it makes it altogether unworthy
the honour of this spiritual priesthood. Oh! this is a large task, an
infinite task. The several creatures bear their part in this; the sun
says somewhat, and moon and stars, yea, the lowest have some
share in it; the very plants and herbs of the field speak of God; and
yet, the very highest and best, yea all of them together, the whole
concert of Heaven and earth, cannot show forth all His praise to the
full. No, it is but a part, the smallest part of that glory, which they
can reach.

APHORISM XXVIII.
Despise none: Despair of none.

Leighton.

The Jews would not willingly tread upon the smallest piece of
paper in their way, but took it up; for possibly, said they, the name
of God may be on it. Though there was a little superstition in this,
yet truly there is nothing but good religion in it, if we apply it to
men. Trample not on any; there may be some work of grace there,
that thou knowest not of. The name of God may be written upon
that soul thou treadest on; it may be a soul that Christ thought so
much of, as to give His precious blood for it; therefore despise it not.
APHORISM XXIX.
Men of Least Merit most apt to be Contemptuous, Because most
Ignorant and most Overweening of Themselves.

Leighton.

Too many take the ready course to deceive themselves; for they
look with both eyes on the failings and defects of others, and
scarcely give their good qualities half an eye, while on the contrary,
in themselves, they study to the full their own advantages, and their
weaknesses and defects, (as one says), they skip over, as children
do their hard words in their lesson, that are troublesome to read;
and making this uneven parallel, what wonder if the result be a
gross mistake of themselves!

APHORISM XXX.
Vanity may strut in rags, and Humility be arrayed in purple and
fine linen.

Leighton.

It is not impossible that there may be in some an affected pride in


the meanness of apparel, and in others, under either neat or rich
attire, a very humble unaffected mind: using it upon some of the
afore-mentioned engagements, or such like, and yet the heart not at
all upon it. Magnus qui fictilibus ubitur tanquam argento, nec ille
minor qui argento tanquam fictilibus, says Seneca: Great is he who
enjoys his earthenware as if it were plate, and not less great is the
man to whom all his plate is no more than earthenware.

APHORISM XXXI.
Of the Detraction among Religious Professors.
Leighton and Coleridge.

They who have attained to a self-pleasing pitch of civility or formal


religion, have usually that point of presumption with it, that they
make their own size the model and rule to examine all by. What is
below it, they condemn indeed as profane; but what is beyond it,
they account needless and affected preciseness; and therefore are
as ready as others to let fly invectives or bitter taunts against it,
which are the keen and poisoned shafts of the tongue, and a
persecution that shall be called to a strict account.
The slanders, perchance, may not be altogether forged or untrue;
they may be the implements, not the inventions, of Malice. But they
do not on this account escape the guilt of detraction. Rather, it is
characteristic of the evil spirit in question, to work by the advantage
of real faults; but these stretched and aggravated to the utmost. It
is not expressible how deep a wound a tongue sharpened to this work will
give, with no noise and a very little word. This is the true white
gunpowder, which the dreaming Projectors of silent Mischiefs and
insensible Poisons sought for in the Laboratories of Art and Nature,
in a World of Good; but which was to be found, in its most
destructive form, in "the World of Evil, the Tongue."

APHORISM XXXII.
The Remedy.

Leighton.

All true remedy must begin at the heart; otherwise it will be but a
mountebank cure, a false imagined conquest. The weights and
wheels are there, and the clock strikes according to their motion.
Even he that speaks contrary to what is within him, guilefully
contrary to his inward conviction and knowledge, yet speaks
conformably to what is within him in the temper and frame of his
heart, which is double, a heart and a heart, as the Psalmist hath it:
Psalm xii. 2.

APHORISM XXXIII.
Leighton and Coleridge.

It is an argument of a candid ingenuous mind, to delight in the


good name and commendations of others; to pass by their defects,
and take notice of their virtues; and to speak and hear of those
willingly, and not endure either to speak or hear of the other; for in
this indeed you may be little less guilty than the evil speaker, in
taking pleasure in it, though you speak it not. He that willingly drinks
in tales and calumnies, will, from the delight he hath in evil hearing,
slide insensibly into the humour of evil speaking. It is strange how
most persons dispense with themselves in this point, and that in
scarcely any societies shall we find a hatred of this ill, but rather
some tokens of taking pleasure in it; and until a Christian sets
himself to an inward watchfulness over his heart, not suffering in it
any thought that is uncharitable, or vain self-esteem, upon the sight
of others' frailties, he will still be subject to somewhat of this, in the
tongue or ear at least. So, then, as for the evil of guile in the
tongue, a sincere heart, truth in the inward parts, powerfully
redresses it; therefore it is expressed, Psal. xv. 2, That speaketh the
truth from his heart; thence it flows. Seek much after this, to speak
nothing with God, nor men, but what is the sense of a single
unfeigned heart. O sweet truth! excellent but rare sincerity! he that
loves that truth within, and who is himself at once the truth and the
life, He alone can work it there! Seek it of him.

It is characteristic of the Roman dignity and sobriety, that, in the


Latin, to favour with the tongue (favere lingua) means to be silent.
We say, Hold your tongue! as if it were an injunction, that could not
be carried into effect but by manual force, or the pincers of the
Forefinger and Thumb! And verily—I blush to say it—it is not Women
and Frenchmen only that would rather have their tongues bitten
than bitted, and feel their souls in a strait-waistcoat, when they are
obliged to remain silent.

APHORISM XXXIV.
On the Passion for New and Striking Thoughts.

Leighton.

In conversation seek not so much either to vent thy knowledge, or


to increase it, as to know more spiritually and effectually what thou
dost know. And in this way those mean despised truths, that
everyone thinks he is sufficiently seen in, will have a new sweetness
and use in them, which thou didst not so well perceive before (for
these flowers cannot be sucked dry), and in this humble sincere way
thou shalt grow in grace and in knowledge too.

APHORISM XXXV.
The Radical Difference between the Good Man and the Vicious
Man.

Leighton and Coleridge.

The godly man hates the evil he possibly by temptation hath been
drawn to do, and loves the good he is frustrated of, and, having
intended, hath not attained to do. The sinner, who hath his
denomination from sin as his course, hates the good which
sometimes he is forced to do, and loves that sin which many times
he does not, either wanting occasion and means, so that he cannot
do it, or through the check of an enlightened conscience possibly
dares not do; and though so bound up from the act, as a dog in a
chain, yet the habit, the natural inclination and desire in him, is still
the same, the strength of his affection is carried to sin. So in the
weakest sincere Christian, there is that predominant sincerity and
desire of holy walking, according to which he is called a righteous
person, the Lord is pleased to give him that name, and account him
so, being upright in heart, though often failing.
Leighton adds, "There is a Righteousness of a higher strain." I do
not ask the reader's full assent to this position: I do not suppose him
as yet prepared to yield it. But thus much he will readily admit, that
here, if any where, we are to seek the fine Line which, like stripes of
Light in Light, distinguishes, not divides, the summit of religious
Morality from Spiritual Religion.
"A Righteousness" (Leighton continues) "that is not in him, but
upon him. He is clothed with it." This, reader! is the controverted
Doctrine, so warmly asserted and so bitterly decried under the name
of "imputed righteousness." Our learned Archbishop, you see, adopts it;
and it is on this account principally, that by many of our leading
Churchmen his orthodoxy has been more than questioned, and his
name put in the list of proscribed divines, as a Calvinist. That
Leighton attached a definite sense to the words above quoted, it
would be uncandid to doubt; and the general spirit of his writings
leads me to presume that it was compatible with the eternal
distinction between things and persons, and therefore opposed to
modern Calvinism. But what it was, I have not (I own) been able to
discover. The sense, however, in which I think he might have
received this doctrine, and in which I avow myself a believer in it, I
shall have an opportunity of showing in another place. My present
object is to open out the road by the removal of prejudices, so far at
least as to throw some disturbing doubts on the secure taking-for-
granted, that the peculiar Tenets of the Christian Faith asserted in
the articles and homilies of our National Church are in contradiction
to the common sense of mankind. And with this view, (and not in
the arrogant expectation or wish, that a mere ipse dixit should be
received for argument) I here avow my conviction, that the doctrine
of imputed Righteousness, rightly and scripturally interpreted, is so far
from being either irrational or immoral, that Reason itself prescribes
the idea in order to give a meaning and an ultimate object to
Morality; and that the Moral Law in the Conscience demands its
reception in order to give reality and substantive existence to the
idea presented by the Reason.

APHORISM XXXVI.
Leighton.

Your blessedness is not,—no, believe it, it is not where most of


you seek it, in things below you. How can that be? It must be a
higher good to make you happy.

Comment.
Every rank of creatures, as it ascends in the scale of creation,
leaves death behind it or under it. The metal at its height of being
seems a mute prophecy of the coming vegetation, into a mimic
semblance of which it crystallizes. The blossom and flower, the acme
of vegetable life, divides into correspondent organs with reciprocal
functions, and by instinctive motions and approximations seems
impatient of that fixure, by which it is differenced in kind from the
flower-shaped Psyche, that flutters with free wing above it. And
wonderfully in the insect realm doth the Irritability, the proper seat
of Instinct, while yet the nascent Sensibility is subordinated thereto
—most wonderfully, I say, doth the muscular life in the insect, and
the musculo-arterial in the bird, imitate and typically rehearse the
adaptive Understanding, yea, and the moral affections and charities,
of man. Let us carry ourselves back, in spirit, to the mysterious
Week, the teeming Work-days of the Creator: as they rose in vision
before the eye of the inspired historian of the Generations of the
Heaven and the Earth, in the days that the Lord God made the Earth
and the Heavens.[57] And who that hath watched their ways with an
understanding heart, could, as the vision evolving, still advanced
towards him, contemplate the filial and loyal bee; the home-building,
wedded, and divorceless swallow; and above all the manifoldly
intelligent[58] ant tribes, with their Commonwealths and
Confederacies, their warriors and miners, the husbandfolk, that fold
in their tiny flocks on the honeyed leaf, and the virgin sisters, with
the holy instincts of maternal love, detached and in selfless purity—
and not say to himself, Behold the Shadow of approaching Humanity,
the Sun rising from behind, in the kindling Morn of Creation! Thus all
lower Natures find their highest Good in semblances and seekings of
that which is higher and better. All things strive to ascend, and
ascend in their striving. And shall man alone stoop? Shall his pursuits
and desires, the reflections of his inward life, be like the reflected
image of a tree on the edge of a pool, that grows downward, and
seeks a mock heaven in the unstable element beneath it, in
neighbourhood with the slim water-weeds and oozy bottom-grass
that are yet better than itself and more noble, in as far as
Substances that appear as Shadows are preferable to Shadows
mistaken for Substance! No! it must be a higher good to make you
happy. While you labour for any thing below your proper Humanity,
you seek a happy Life in the region of Death. Well saith the moral
poet—
Unless above himself he can
Erect himself, how mean a thing is man![59]

[57] Gen. ii. 4.—Ed.


[58] See Hüber on Bees, and on Ants.
[59] Samuel Daniel, 1562-1619:—
Unless above himself he can
Erect himself, how poor a thing is man!
To the Countess of Cumberland, stanza 12.—
Ed.

APHORISM XXXVII.
Leighton.

There is an imitation of men that is impious and wicked, which


consists in taking a copy of their sins. Again, there is an imitation
which though not so grossly evil, yet is poor and servile, being in
mean things, yea, sometimes descending to imitate the very
imperfections of others, as fancying some comeliness in them: as
some of Basil's scholars, who imitated his slow speaking, which he
had a little in the extreme, and could not help. But this is always
laudable, and worthy of the best minds, to be imitators of that which
is good, wheresoever they find it; for that stays not in any man's
person, as the ultimate pattern, but rises to the highest grace, being
man's nearest likeness to God, His image and resemblance, bearing
his stamp and superscription, and belonging peculiarly to Him, in
what hand soever it be found, as carrying the mark of no other
owner than Him.

APHORISM XXXVIII.
Leighton.

Those who think themselves high-spirited, and will bear least, as


they speak, are often, even by that, forced to bow most, or to burst
under it; while humility and meekness escape many a burden, and
many a blow, always keeping peace within, and often without too.

APHORISM XXXIX.
Leighton.
Our condition is universally exposed to fears and troubles, and no
man is so stupid but he studies and projects for some fence against
them, some bulwark to break the incursion of evils, and so to bring
his mind to some ease, ridding it of the fear of them. Thus men seek
safety in the greatness, or multitude, or supposed faithfulness of
friends; they seek by any means to be strongly underset this way; to
have many, and powerful, and trust-worthy friends. But wiser men,
perceiving the unsafety and vanity of these and all external things,
have cast about for some higher course. They see a necessity of
withdrawing a man from externals, which do nothing but mock and
deceive those most who trust most to them; but they cannot tell
whither to direct him. The best of them bring him into himself, and
think to quiet him so; but the truth is, he finds as little to support
him there; there is nothing truly strong enough within him, to hold
out against the many sorrows and fears which still from without do
assault him. So then, though it is well done, to call off a man from
outward things, as moving sands, that he build not on them, yet,
this is not enough; for his own spirit is as unsettled a piece as is in
all the world, and must have some higher strength than its own, to
fortify and fix it. This is the way that is here taught, Fear not their
fear, but sanctify the Lord your God in your hearts; and if you can
attain this latter, the former will follow of itself.

APHORISM XL.
Worldly Troubles Idols.

Leighton.

The too ardent love or self-willed desire of power, or wealth, or


credit in the world, is (an Apostle has assured us) Idolatry. Now
among the words or synonimes for idols, in the Hebrew language,
there is one that in its primary sense signifies troubles (tegirim),
other two that signify terrors (miphletzeth and emim). And so it is
certainly. All our idols prove so to us. They fill us with nothing but
anguish and troubles, with cares and fears, that are good for nothing
but to be fit punishments of the folly, out of which they arise.

APHORISM XLI.
On the right Treatment of Infidels.

Leighton and Coleridge.

A regardless contempt of infidel writings is usually the fittest


answer; Spreta vilescerent. But where the holy profession of
Christians is likely to receive either the main or the indirect blow,
and a word of defence may do any thing to ward it off, there we
ought not to spare to do it.
Christian prudence goes a great way in the regulating of this.
Some are not capable of receiving rational answers, especially in
Divine things; they were not only lost upon them, but religion
dishonoured by the contest.
Of this sort are the vulgar railers at religion, the foul-mouthed
beliers of the Christian faith and history. Impudently false and
slanderous assertions can be met only by assertions of their
impudent and slanderous falsehood: and Christians will not, must
not, condescend to this. How can mere railing be answered by them
who are forbidden to return a railing answer? Whether, or on what
provocations, such offenders may be punished or coerced on the
score of incivility, and ill-neighbourhood, and for abatement of a
nuisance, as in the case of other scolds and endangerers of the
public peace, must be trusted to the discretion of the civil
magistrate. Even then, there is danger of giving them importance,
and flattering their vanity, by attracting attention to their works, if
the punishment be slight; and if severe, of spreading far and wide
their reputation as martyrs, as the smell of a dead dog at a distance
is said to change into that of musk. Experience hitherto seems to
favour the plan of treating these bêtes puantes and enfans de
diable, as their four-footed brethren, the skink and squash, are
treated[60] by the American woodmen, who turn their backs upon
the fetid intruder, and make appear not to see him, even at the cost
of suffering him to regale on the favourite viand of these animals,
the brains of a stray goose or crested thraso of the dunghill. At all
events, it is degrading to the majesty, and injurious to the character
of Religion, to make its safety the plea for their punishment, or at all
to connect the name of Christianity with the castigation of
indecencies that properly belong to the beadle, and the perpetrators
of which would have equally deserved his lash, though the religion
of their fellow-citizens, thus assailed by them, had been that of Fo or
Juggernaut.
On the other hand, we are to answer every one that inquires a
reason, or an account; which supposes something receptive of it. We
ought to judge ourselves engaged to give it, be it an enemy, if he
will hear; if it gain him not, it may in part convince and cool him;
much more, should it be one who ingenuously inquires for
satisfaction, and possibly inclines to receive the truth, but has been,
prejudiced by misrepresentations of it.

[60] About the end of the same year (says Kalm), another of
these Animals (Mephitis Americana) crept into our cellar; but did
not exhale the smallest scent, because it was not disturbed. A
foolish old woman, however, who perceived it at night, by the
shining, and thought, I suppose, that it would set the world on
fire, killed it: and at that moment its stench began to spread.
We recommend this anecdote to the consideration of sundry old
women, on this side of the Atlantic, who, though they do not
wear the appropriate garment, are worthy to sit in their
committee-room, like Bickerstaff in the Tatler, under the canopy
of their grandam's hoop-petticoat.
APHORISM XLII.
Passion no Friend to Truth.

Leighton.

Truth needs not the service of passion; yea, nothing so disserves


it, as passion when set to serve it. The Spirit of truth is withal the
Spirit of meekness. The Dove that rested on that great champion of
truth, who is The Truth itself, is from Him derived to the lovers of
truth, and they ought to seek the participation of it. Imprudence
makes some kind of Christians lose much of their labour, in speaking
for religion, and drive those further off, whom they would draw into
it.
The confidence that attends a Christian's belief makes the believer
not fear men, to whom he answers, but still he fears his God, for
whom he answers, and whose interest is chief in those things he
speaks of. The soul that hath the deepest sense of spiritual things,
and the truest knowledge of God, is most afraid to miscarry in
speaking of Him, most tender and wary how to acquit itself when
engaged to speak of and for God.[61]

[61] To the same purpose are the two following sentences from
Hilary:
Etiam quæ pro Religione dicimus, cum grandi motu et disciplina
dicere debemus.—Hilarius de Trinit. Lib. 7.
Non relictus est hominum eloquiis de Dei rebus alius quam Dei
sermo.—Idem.
The latter, however, must be taken with certain qualifications and
exceptions; as when any two or more texts are in apparent
contradiction, and it is required to state a Truth that
comprehends and reconciles both, and which, of course, cannot
be expressed in the words of either,—for example, the filial
subordination (My Father is greater than I), in the equal Deity
(My Father and I are one).

APHORISM XLIII.
On the Conscience.

Leighton.

It is a fruitless verbal debate, whether Conscience be a Faculty or


a Habit. When all is examined, Conscience will be found to be no
other than the mind of a man, under the notion of a particular
reference to himself and his own actions.

Comment.
What Conscience is, and that it is the ground and antecedent of
human (or self-) consciousness, and not any modification of the
latter, I have shown at large in a work announced for the press, and
described in the Chapter following.[62] I have selected the preceding
extract as an Exercise for Reflection; and because I think that in too
closely following Thomas à Kempis, the Archbishop has strayed from
his own judgment. The definition, for instance, seems to say all, and
in fact says nothing; for if I asked, How do you define the human
mind? the answer must at least contain, if not consist of, the words,
"a mind capable of Conscience." For Conscience is no synonime of
Consciousness, nor any mere expression of the same as modified by
the particular Object. On the contrary, a Consciousness properly
human (that is, Self-consciousness), with the sense of moral
responsibility, presupposes the Conscience, as its antecedent
condition and ground. Lastly, the sentence, "It is a fruitless verbal
debate," is an assertion of the same complexion with the
contemptuous sneers, at verbal criticism by the contemporaries of
Bentley. In questions of Philosophy or Divinity, that have occupied
the learned and been the subjects of many successive controversies,
for one instance of mere logomachy I could bring ten instances of
logodædaly, or verbal legerdemain, which have perilously confirmed
prejudices, and withstood the advancement of truth in consequence
of the neglect of verbal debate, that is, strict discussion of terms. In
whatever sense, however, the term Conscience may be used, the
following Aphorism is equally true and important. It is worth
noticing, likewise, that Leighton himself in a following page (vol. ii.
p. 97), tells us that a good Conscience is the root of a good
Conversation: and then quotes from St. Paul a text, Titus i. 15, in
which the Mind and the Conscience are expressly distinguished.

[62] See Aphorisms on Spiritual Religion, p. 103.—Ed.

APHORISM XLIV.
The Light of Knowledge a necessary accompaniment of a Good
Conscience.

Leighton.

If you would have a good conscience, you must by all means have
so much light, so much knowledge of the will of God, as may
regulate you, and show you your way, may teach you how to do,
and speak, and think, as in His presence.

APHORISM XLV.
Yet the Knowledge of the Rule, though Accompanied by an
endeavour to accommodate our conduct to this Rule, will not of itself
form a Good Conscience.

Leighton.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like