Multimodal queries

In the default database, ShrikeDB can use vector search to select graph nodes, traverse relationships from those nodes, and read a KV value for each result. Use the same node UID for its graph record, vector entry, and KV key.

Prepare the data

Create MixedUser nodes and KNOWS relationships with Cypher. Keep the UIDs returned for the nodes. Insert each embedding into the named vector index with BulkInsertVectors, setting entity_id to the matching node UID. The query vector must have the index’s dimension and use the same embedding model.

To attach a payload, call PutKeyValue with the node UID as key and the payload bytes as value. This API writes to the default KV namespace. A UTF-8 payload appears as a string in the Cypher result; other bytes remain bytes. The current PutKeyValue handler does not use schema_id to select a KV namespace.

See Your first multimodal dataset for database setup and Vector search for vector index configuration.

Submit this query through ExecuteCypher. It searches the vector index, then follows one directed KNOWS relationship from each selected user.

CALL vector.knn("default", [0.0, 0.0], 8, {ef: 64})
YIELD node AS user, score
MATCH (user:MixedUser)-[:KNOWS]->(friend:MixedUser)
RETURN user, friend, score
LIMIT 20

k bounds the vector candidates before graph expansion. LIMIT bounds the returned relationship rows; one candidate can produce several rows. Scores follow the vector index’s metric. Choose k for the candidate pool you want to examine, then inspect the graph results.

Include a KV payload

Add a dependent KV read to return metadata for each selected user. The string argument names the same public namespace used by PutKeyValue.

CALL vector.knn("default", [0.0, 0.0], 8, {ef: 64})
YIELD node AS user, score
MATCH (user:MixedUser)-[:KNOWS]->(friend:MixedUser)
CALL kv.get("default", user) YIELD value AS metadata
RETURN user, friend, score, metadata
LIMIT 20

The server reads metadata after graph expansion and the result limit. If a user has several matching friends, the query reuses that user’s KV value. Access to the KV namespace requires read permission for that namespace in addition to query permission.