Skip to main content

Entities

Named entities extracted from memories to build a knowledge graph.

What are Entities?

Entities are named things (people, organizations, places, etc.) automatically extracted from your memories. They form the nodes of a knowledge graph that connects related information.

entity-example.json
// Entity extracted from memories
{
  "id": "ent_abc123",
  "name": "John Smith",
  "type": "person",
  "attributes": {
    "role": "colleague",
    "department": "Engineering"
  },
  "aliases": ["John", "JS"],
  "mention_count": 15
}

Entity Types

Entities are classified into types:

  • person - People (colleagues, friends, contacts)
  • organization - Companies, teams, groups
  • location - Places, cities, addresses
  • date - Dates, time periods
  • product - Products, tools, software
  • concept - Abstract concepts, topics
  • event - Meetings, conferences, milestones
  • skill - Technologies, abilities

Querying Entities

List and filter entities:

import { Trix } from '@trixdb/client';

const trix = new Trix({ apiKey: process.env.TRIX_API_KEY });

// List all entities
const entities = await trix.entities.list();

// Filter by type
const people = await trix.entities.list({
  type: 'person'
});

// Get entity details
const entity = await trix.entities.get('ent_abc123');

console.log(entity.name);        // "John Smith"
console.log(entity.type);        // "person"
console.log(entity.attributes);  // { role: "colleague", ... }

Entity Relationships

Entities are connected by relationships, forming a knowledge graph:

import { Trix } from '@trixdb/client';

const trix = new Trix({ apiKey: process.env.TRIX_API_KEY });

// Get relationships for an entity
const relationships = await trix.entities.getRelationships('ent_abc123');

// Each relationship includes target entity and type
relationships.forEach(rel => {
  console.log(`${rel.relationshipType}: ${rel.target.name}`);
  console.log(`Strength: ${rel.strength}`);
});

// Example output:
// works_at: Google (strength: 0.95)
// knows: Jane Doe (strength: 0.8)

Graph Traversal

Explore the knowledge graph with traversal operations:

import { Trix } from '@trixdb/client';

const trix = new Trix({ apiKey: process.env.TRIX_API_KEY });

// Get subgraph around an entity (2-hop neighborhood)
const subgraph = await trix.graph.subgraph('ent_abc123', {
  hops: 2
});

console.log(`Nodes: ${subgraph.nodes.length}`);
console.log(`Edges: ${subgraph.edges.length}`);

// Find path between two entities
const path = await trix.graph.findPath({
  from: 'ent_abc123',
  to: 'ent_xyz789'
});

// Show connection path
path.nodes.forEach((node, i) => {
  if (i < path.edges.length) {
    console.log(`${node.name} --[${path.edges[i].type}]--> `);
  } else {
    console.log(node.name);
  }
});

Graph traversal is useful for discovering indirect connections - like finding how two people might be connected through mutual contacts or organizations.