Recollect.GraphStore behaviour (recollect v0.5.1)

Copy Markdown View Source

Behaviour for graph storage backends.

Default implementation uses PostgreSQL recursive CTEs. Can be swapped for KuzuDB, Apache AGE, or other graph stores.

Summary

Callbacks

Get entities within N hops of a starting entity.

Get all relations involving an entity.

Functions

Get the configured graph store implementation.

Types

entity()

@type entity() :: %{
  id: String.t(),
  name: String.t(),
  entity_type: String.t(),
  description: String.t(),
  mention_count: integer()
}

relation()

@type relation() :: %{
  from_id: String.t(),
  to_id: String.t(),
  relation_type: String.t(),
  weight: float()
}

Callbacks

get_neighbors(owner_id, entity_id, hops)

@callback get_neighbors(
  owner_id :: String.t(),
  entity_id :: String.t(),
  hops :: pos_integer()
) ::
  {:ok, [entity()]} | {:error, term()}

Get entities within N hops of a starting entity.

get_relations(owner_id, entity_id)

@callback get_relations(owner_id :: String.t(), entity_id :: String.t()) ::
  {:ok, [relation()]} | {:error, term()}

Get all relations involving an entity.

Functions

impl()

Get the configured graph store implementation.