Examples for Neo4J database queries

(TODO: introduction to neo4j console)

Finding all texts by Jaghmini

The following command finds all texts that were created by Jaghmini. To do this we need to MATCH all TEXT objects that have a was_created_by relation to the person object with the ismi_id 7437 and return the title and (if known) creation date attributes of the text objects:

MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: 7437})
RETURN t.full_title_translit as title, t.creation_date as date

You can change the ismi_id number to the number of another author e.g. 47316 for Tusi to get a list of all his works in the database.

Finding the number of witnesses

With the following command we also count the number of witnesses to each text. For this we add an OPTIONAL MATCH clause (otherwise we would not get the texts that have no witnesses) that matches all witnesses that have a is_exemplar_of relation to the text. To just get the number of witnesses instead of a list of all of them we use the count(w) aggregation function in the RETURN clause.

MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: 7437})
OPTIONAL MATCH (w:WITNESS)-[:is_exemplar_of]->(t)
RETURN t.full_title_translit as title, t.creation_date as date, count(w) as witnesses

 

Finding the date range of witnesses

With the following command we also add the minimum and maximum copy dates of the witnesses using the min and max aggregation functions. We also add the number of identified copy dates. This is important to get an impression of the ratio of dated and undated witnesses.

MATCH (t:TEXT)-[:was_created_by]->(p:PERSON {ismi_id: 7437})
OPTIONAL MATCH (w:WITNESS)-[:is_exemplar_of]->(t)
RETURN t.ismi_id as id,
t.full_title_translit as title, t.creation_date as date,
count(w) as num_wit, count(w.creation_date) as num_dates,
min(toInteger(w.creation_date)) as min_date, max(toInteger(w.creation_date)) as max_date

List all (direct) witnesses of Jaghminis Mulakhkhas (with date and place)

The following command produces a list of all direct witnesses of Jaghmini's Mulakhkhas with their copy date and the copy place with coordinates.

The resulting table can be downloaded as a CSV file using the "Export CSV" button on top of the table. The CSV file can then be uploaded and used with the Platin geobrowser tool to visualize the local and temporal distribution of witnesses.

When using these visualizations keep in mind the low number and possible bias of identified copy dates and places.

MATCH (w:WITNESS)-[:is_exemplar_of]->(t:TEXT {ismi_id:161559})
OPTIONAL MATCH (w)-[:was_copied_in]-(p)
RETURN w.ismi_id as id,
w._label as witness, w.creation_date as TimeStamp,
p.name as place, p.longitude as Longitude, p.latitude as Latitude

Graph of commentary relations

The following command finds all texts (t1) that have a commentary relation (is_commentary_on) on another text (t2) and returns the result as a graph. The result is a big graph that consists of lots of small subgraphs and is hard to view.

MATCH (t1:TEXT)-[r:is_commentary_on]->(t2:TEXT)
RETURN t1,r,t2

To get a graph of only the commentaries that are related to Jaghmini's Mulakhkhas we add a WHERE clause that constrains the result to just the texts that are related through one or more (that's the * at the end) is_commentary_on relations to this specific text (which has the ismi_id 161559).

MATCH (t1:TEXT)-[r:is_commentary_on]->(t2:TEXT)
WHERE (t1)-[:is_commentary_on*]->({ismi_id:161559})
RETURN t1,r,t2