Skip to content

Graph Namespace Utils

Graph node ID namespacing utilities.

build_cypher_chunk_id_match(chunk_id, index_name, use_namespaced_id=True)

Build the Cypher Chunk-id match clause and its bind parameters for one chunk id.

Parameters:

Name Type Description Default
chunk_id str

Raw (un-namespaced) chunk identifier.

required
index_name str

Namespace scoping the lookup.

required
use_namespaced_id bool

Whether the predicate also matches the namespaced ({index_name}:{chunk_id}) form. Defaults to True.

True

Returns:

Type Description
tuple[str, dict[str, Any]]

tuple[str, dict[str, Any]]: The parenthesized Cypher predicate matching the chunk's id (the Chunk node must be bound as c), and the bind parameters it references.

build_namespaced_id(raw_id, index_name)

Return a namespaced node identifier.

When index_name is provided, the returned id takes the form "{index_name}:{raw_id}", scoping the node to a single pipeline's namespace. When index_name is None the raw id is returned unchanged, preserving backwards compatibility with deployments that predate namespacing.

Parameters:

Name Type Description Default
raw_id str

Raw, un-namespaced node identifier.

required
index_name str | None

Namespace prefix to prepend, or None to return raw_id unchanged.

required

Returns:

Name Type Description
str str

The namespaced id "{index_name}:{raw_id}", or raw_id when index_name is None.