Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion snippets/general-shared-text/neo4j-graph.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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
```