### Project Commands
Source: https://github.com/graphrag/graphrag.github.io/blob/main/DEVELOP.md
Lists common npm commands for managing and running a Starlight project. These commands cover installation, development server, building, and previewing.
```bash
npm install
npm run dev
npm run build
npm run preview
npm run astro ...
npm run astro -- --help
```
--------------------------------
### Relationship Syntax Examples
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/appendices/notation.md
Illustrates how to define relationships between nodes in the Graph Pattern Notation, including direction, labels, and properties.
```gram
(a)-[:SIMILAR]->(b)
- a relationship from `a` to `b` labeled as `SIMILAR`
(a)<-[:SIMILAR]-(c)
- a relationship from `c` to `a` labeled as `SIMILAR`
(a)-[:SIMILAR {score:0.8}]->(b)
- a relationship with a record
(a)=[::SIMILAR {score::0.0..1.0}]=>(b)
- a relationship declaration, stating that the `score` value of `SIMILAR` relationships should be a decimal in the range of 0.0 and 0.1
```
--------------------------------
### Node Syntax Examples
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/appendices/notation.md
Demonstrates various ways to define nodes in the Graph Pattern Notation, including identifiers, labels, properties, and metadata.
```gram
(a)
- a single node identified as `a`
(c:Chunk)
- a single node labeled as a `Chunk`
(s:Summary:Synthesized)
- single node with two labels
(c:Chunk {text:"something something"})
- labeled node with a record defining property `text` to be a string value
(::Chunk {text::string})
- node with record declaring `text` to be a `string` on Nodes labeled as `Chunk`
(c:Chunk {seq@42})
- record defining metadata property `seq` as an integer value
- metadata property names are in a separate namespace
- typically used for implementation detail rather than intrinsic qualities
```
--------------------------------
### Subject Syntax Examples (Set Membership)
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/appendices/notation.md
Details how subjects can associate with multiple elements using the pipe (`|`) associator for set membership, including labeled associations.
```gram
[a | i]
- subject `a` about another element `i`
- known as an "annotation"
- example: ```[:Validation {approved:true} | (c:Chunk)]```
[a | i,j,k]
- subject about 3 other elements
[a |:R| i,j,k]
- subject with labeled association of members
- provides explicit
- example: ```[d:Document |:SPLIT_INTO| c1, c2, c3]```
```
--------------------------------
### Subject Syntax Examples (No Association)
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/appendices/notation.md
Shows how subjects are defined without explicit associations, similar to nodes but enclosed in square brackets.
```gram
[a]
- Subject `a` about no other elements
[c:Chunk]
- Subject labeled as a `Chunk`
[s:Summary:Synthesized]
- Subject with two labels
[c:Chunk {text:"something something"}]
- labeled Subject with a record defining property `text` with a string value
```
--------------------------------
### Cypher Retrieval Query for Graph Traversal
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/reference/graphrag/graph-enhanced-vector-search.md
Example Cypher query demonstrating how to retrieve data by matching nodes, performing a graph traversal starting from entities, and returning relevant information. This query is part of a graph-enhanced vector search strategy to enrich context beyond simple vector similarity.
```cypher
MATCH (node)-[:PART_OF]->(d:Document)
CALL {
WITH node
MATCH (node)-[:HAS_ENTITY]->(e)
MATCH path=(e)(()-[rels:!HAS_ENTITY&!PART_OF]-()){0,2}(:!Chunk&!Document)
…
RETURN …
}
RETURN …
```
--------------------------------
### Python: Implement GraphRAG Retrieval Query with Neo4jVector
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/concepts/intro-to-graphrag.md
Demonstrates how to define a retrieval query for GraphRAG and use it with Neo4jVector for similarity search. This example shows fetching node names, scores, and metadata from an existing Neo4j index using LangChain and OpenAI embeddings.
```python
retrieval_query = ""
RETURN "Name: " + node.name AS text, score, {source:node.url} AS metadata
"
retrieval_example = Neo4jVector.from_existing_index(
OpenAIEmbeddings(),
url=url,
username=username,
password=password,
index_name="person_index",
retrieval_query=retrieval_query,
)
retrieval_example.similarity_search("Jon Snow", k=1)
```
--------------------------------
### Starlight Project Structure
Source: https://github.com/graphrag/graphrag.github.io/blob/main/DEVELOP.md
Illustrates the typical directory and file structure for a project initialized with the Starlight starter kit. It highlights key directories for content, assets, and configuration.
```bash
.\\
├── public/\\
├── src/\\
│ ├── assets/\\
│ ├── content/\\
│ │ ├── docs/\\
│ │ └── config.ts\\
│ └── env.d.ts\\
├── astro.config.mjs\\
├── package.json\\
└── tsconfig.json
```
--------------------------------
### Create Starlight Project
Source: https://github.com/graphrag/graphrag.github.io/blob/main/DEVELOP.md
Command to create a new Astro project using the Starlight template. This is the initial step to set up your documentation site.
```bash
npm create astro@latest -- --template starlight
```
--------------------------------
### Astro LinkCard Component Usage
Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/index.mdx
Demonstrates the usage of the Astro 'LinkCard' component to create navigation elements. Each card links to a specific section of the documentation, providing a title, description, and the target URL.
```astro