diff --git a/snippets/general-shared-text/neo4j-graph.mdx b/snippets/general-shared-text/neo4j-graph.mdx index fe1d43e9..05f2d7bf 100644 --- a/snippets/general-shared-text/neo4j-graph.mdx +++ b/snippets/general-shared-text/neo4j-graph.mdx @@ -61,4 +61,64 @@ In the preceding diagram: - Each `UnstructuredElement` node has a `PART_OF_CHUNK` relationship with a `Chunk` element. - Each `Chunk` node, except for the "last" `Chunk` node, has a `NEXT_CHUNK` relationship with its "next" `Chunk` node. -Learn more about [document elements](/platform/document-elements) and [chunking](/platform/chunking). \ No newline at end of file +Learn more about [document elements](/platform/document-elements) and [chunking](/platform/chunking). + +Some related example Neo4j graph queries include the following. + +Query for all nodes: + +```text +MATCH (n) +RETURN n +``` + +Query for `Chunk` to `Document` relationships: + +```text +MATCH (chunk:Chunk)-[:PART_OF_DOCUMENT]->(doc:Document) +RETURN chunk, doc +``` + +Query for `UnstructuredElement` to `Document` relationships: + +```text +MATCH (element:UnstructuredElement)-[:PART_OF_DOCUMENT]->(doc:Document) +RETURN element, doc +``` + +Query for `UnstructuredElement` to `Chunk` relationships: + +```text +MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]->(chunk:Chunk) +RETURN element, chunk +``` + +Query for `Chunk` to `Chunk` relationships: + +```text +MATCH (this:Chunk)-[:NEXT_CHUNK]->(previous:Chunk) +RETURN this, previous +``` + +Query for `UnstructuredElement` to `Chunk` to `Document` relationships: + +```text +MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]-(chunk:Chunk)-[:PART_OF_DOCUMENT]->(doc:Document) +RETURN element, chunk, doc +``` + +Query for `UnstructuredElements` containing the text `jury`, and show their `Chunk` relationships: + +```text +MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]->(chunk:Chunk) +WHERE element.text =~ '(?i).*jury.*' +RETURN element, chunk +``` + +Query for the `Chunk` with the specified `id`, and show its `UnstructuredElement` relationships: + +```text +MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]->(chunk:Chunk) +WHERE chunk.id = '731508bf53637ce4431fe93f6028ebdf' +RETURN element, chunk +``` \ No newline at end of file