### 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 ``` ```astro ``` ```astro ``` ```astro ``` ```astro ``` -------------------------------- ### Astro Data Fetching Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/reference/index.mdx Imports necessary functions from 'astro:content' to access collections and fetches all documentation entries. This is a common pattern for dynamic content loading in Astro projects. ```javascript import { getCollection, getEntry } from 'astro:content'; export const pages = await getCollection('docs'); ``` -------------------------------- ### Astro Component Import Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/index.mdx Imports necessary components from the '@astrojs/starlight' library for building the documentation site. These components are used to structure content and create interactive elements like link cards. ```javascript import { LinkCard, CardGrid } from '@astrojs/starlight/components'; ``` -------------------------------- ### Astro Dynamic List Rendering Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/reference/index.mdx Renders lists of pages dynamically using Astro's templating. It filters the fetched 'pages' collection based on specific path prefixes and maps the filtered data to create list items with links. ```astro
    {pages.filter(page => page.id.indexOf("/graphrag/")!=-1).map(page => (
  • {page.data.title}
  • ))}
``` ```astro
    {pages.filter(page => page.id.indexOf("/knowledge-graph/")!=-1).map(page => (
  • {page.data.title}
  • ))}
``` -------------------------------- ### Astro CardGrid Component Usage Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/index.mdx Illustrates the use of the Astro 'CardGrid' component to arrange multiple 'LinkCard' components in a responsive grid layout. This component helps organize related links for better user experience. ```astro ``` ```astro ``` -------------------------------- ### Subject Composition with Pairs Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/appendices/notation.md Demonstrates how a Subject composes two elements into a pair using the '->' arrow notation. This is equivalent to a Relationship when elements are Nodes, or a Path when elements are composable Relationships. ```graphrag-dsl [a:R -> i,j] - Subject composing 2 elements into a pair - equivalent to a Relationship when `i` and `j` are both Nodes - equivalent to a Path when `i` and `j` are composable Relationships (a Relationship where the right-side of `i` is the left side of `j`) - example: ```[:Similar {score:0.87} -> (a:Entity), (b:Entity)]``` ``` -------------------------------- ### Subject Composition with Repeated Elements Source: https://github.com/graphrag/graphrag.github.io/blob/main/src/content/docs/appendices/notation.md Shows how Subject composition can handle sequences with repeated elements, demonstrating flexibility in defining relationships or paths with recurring components. ```graphrag-dsl [a:R {k:"v"} -> i,j,i,k] - Subject composing 3 elements (one of which is repeated) into a sequence - example: ```[:NEXT {cyclic:false} -> (c1:Chunk), (c2:Chunk), c1, (c3:Chunk)]``` ```