@@ -65,60 +65,120 @@ Learn more about [document elements](/ui/document-elements) and [chunking](/ui/c
6565
6666Some related example Neo4j graph queries include the following.
6767
68- Query for all nodes:
68+ Query for all available nodes and relationships :
6969
7070``` text
71- MATCH (n )
72- RETURN n
71+ MATCH path=(source)-[relationship]->(target )
72+ RETURN path
7373```
7474
7575Query for ` Chunk ` to ` Document ` relationships:
7676
7777``` text
78- MATCH (chunk:Chunk)-[:PART_OF_DOCUMENT]->(doc:Document)
79- RETURN chunk, doc
78+ MATCH (chunk:Chunk)-[relationship :PART_OF_DOCUMENT]->(doc:Document)
79+ RETURN chunk, relationship, doc
8080```
8181
8282Query for ` UnstructuredElement ` to ` Document ` relationships:
8383
8484``` text
85- MATCH (element:UnstructuredElement)-[:PART_OF_DOCUMENT]->(doc:Document)
86- RETURN element, doc
85+ MATCH (element:UnstructuredElement)-[relationship :PART_OF_DOCUMENT]->(doc:Document)
86+ RETURN element, relationship, doc
8787```
8888
8989Query for ` UnstructuredElement ` to ` Chunk ` relationships:
9090
9191``` text
92- MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]->(chunk:Chunk)
93- RETURN element, chunk
92+ MATCH (element:UnstructuredElement)-[relationship :PART_OF_CHUNK]->(chunk:Chunk)
93+ RETURN element, relationship, chunk
9494```
9595
9696Query for ` Chunk ` to ` Chunk ` relationships:
9797
9898``` text
99- MATCH (this:Chunk)-[:NEXT_CHUNK]->(previous:Chunk)
100- RETURN this, previous
99+ MATCH (this:Chunk)-[relationship :NEXT_CHUNK]->(previous:Chunk)
100+ RETURN this, relationship, previous
101101```
102102
103103Query for ` UnstructuredElement ` to ` Chunk ` to ` Document ` relationships:
104104
105105``` text
106- MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]-(chunk:Chunk)-[:PART_OF_DOCUMENT]->(doc:Document)
107- RETURN element, chunk, doc
106+ MATCH (element:UnstructuredElement)-[ecrelationship :PART_OF_CHUNK]-(chunk:Chunk)-[cdrelationship :PART_OF_DOCUMENT]->(doc:Document)
107+ RETURN element, ecrelationship, chunk, cdrelationship , doc
108108```
109109
110110Query for ` UnstructuredElements ` containing the text ` jury ` , and show their ` Chunk ` relationships:
111111
112112``` text
113- MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]->(chunk:Chunk)
113+ MATCH (element:UnstructuredElement)-[relationship :PART_OF_CHUNK]->(chunk:Chunk)
114114WHERE element.text =~ '(?i).*jury.*'
115- RETURN element, chunk
115+ RETURN element, relationship, chunk
116116```
117117
118118Query for the ` Chunk ` with the specified ` id ` , and show its ` UnstructuredElement ` relationships:
119119
120120``` text
121- MATCH (element:UnstructuredElement)-[:PART_OF_CHUNK]->(chunk:Chunk)
121+ MATCH (element:UnstructuredElement)-[relationship :PART_OF_CHUNK]->(chunk:Chunk)
122122WHERE chunk.id = '731508bf53637ce4431fe93f6028ebdf'
123- RETURN element, chunk
124- ```
123+ RETURN element, relationship, chunk
124+ ```
125+
126+ Additionally, for the [ Unstructured UI] ( /ui/overview ) and [ Unstructured Workflow Endpoint] ( /api-reference/workflow/ ) ,
127+ when a [ Named entity recognition (NER)] ( /ui/enriching/ner ) DAG node is added to a custom workflow,
128+ any recognized entities are output as ` Entity ` nodes in the graph.
129+
130+ This additional graph ouput of the Neo4j destination connector is represented in the following diagram:
131+
132+ ``` mermaid
133+ graph TD
134+ Chunk -->|HAS_ENTITY| Entity
135+ Entity -->|ENTITY_TYPE| Entity
136+ ```
137+
138+ In the preceding diagram:
139+
140+ - The ` Chunk ` node represents one of the source file's Unstructured ` Element ` objects, after chunking.
141+ - The ` Entity ` node represents a recognized entity.
142+ - A ` Chunk ` node can have ` HAS_ENTITY ` relationships with ` Entity ` nodes.
143+ - An ` Entity ` node can have ` ENTITY_TYPE ` relationships with other ` Entity ` nodes.
144+
145+ Some related example Neo4j graph queries include the following.
146+
147+ Query for all available nodes and relationships:
148+
149+ ``` text
150+ MATCH path=(source)-[relationship]->(target)
151+ RETURN path
152+ ```
153+
154+ Query for ` Entity ` to ` Entity ` relationships:
155+
156+ ``` text
157+ MATCH (child:Entity)-[relationship:ENTITY_TYPE]->(parent:Entity)
158+ RETURN child, relationship, parent
159+ ```
160+
161+ Query for ` Entity ` nodes containing the text ` PERSON ` , and show their ` Entity ` relationships:
162+
163+ ``` text
164+ MATCH (child:Entity)-[relationship:ENTITY_TYPE]->(parent:Entity)
165+ WHERE parent.id = 'PERSON'
166+ RETURN child, relationship, parent
167+ ```
168+
169+ Query for ` Entity ` nodes containing the text ` amendment ` , and show their ` Chunk ` relationships:
170+
171+ ``` text
172+ MATCH (element:Chunk)-[relationship:HAS_ENTITY]->(entity:Entity)
173+ WHERE entity.id =~ '(?i).*amendment.*'
174+ RETURN element, relationship, entity
175+ ```
176+
177+ QUERY FOR ` Entity ` nodes containing the text ` PERSON ` , and show their ` Entity ` to ` Entity ` to ` Chunk ` relationships:
178+
179+ ``` text
180+ MATCH (chunk:Chunk)-[ccrelationship:HAS_ENTITY]-(child:Entity)-[cprelationship:ENTITY_TYPE]->(parent:Entity)
181+ WHERE parent.id =~ 'PERSON'
182+ RETURN chunk, ccrelationship, child, cprelationship, parent
183+ ```
184+
0 commit comments