Triple Intelligence
The core innovation that makes Brainy unique: three types of data intelligence unified in one query.
What is Triple Intelligence?
Triple Intelligence combines three powerful data paradigms into a single, unified query system:
Vector Search
Find content by meaning, not just keywords. Semantic similarity powered by embeddings.
Graph Relationships
Connect entities with typed relationships. Traverse connections naturally.
Metadata Filtering
Query structured data with MongoDB-style operators. Filter by any attribute.
Why Triple Intelligence?
Traditional databases force you to choose one paradigm. Want vector search? Use Pinecone. Need graph relationships? Add Neo4j. Require structured queries? Deploy MongoDB. Suddenly you're managing three databases, three APIs, and three points of failure.
Brainy unifies all three in one system. One query can combine semantic search, relationship traversal, and metadata filtering seamlessly.
Example: All Three in One Query
const results = await brain.find({
// Vector: Find semantically similar content
query: "machine learning algorithms",
// Metadata: Filter by structured attributes
where: {
year: { greaterThanOrEqual: 2020 },
category: "research"
},
// Graph: Only entities connected to this node
connected: {
to: "neural-networks-id",
type: "references"
}
})
This single query finds documents about machine learning from 2020 onwards that reference neural networks. Try doing that with three separate databases!
Vector Search Deep Dive
Vector search uses embeddings to find content by meaning. When you add data to Brainy, it automatically generates embeddings using a built-in model (no API costs).
// These will all match "JavaScript" even though they don't contain the word
await brain.add({ data: "ES6 introduced arrow functions and promises" })
await brain.add({ data: "Node.js runs on the V8 engine" })
await brain.add({ data: "React uses JSX for templating" })
// Find by meaning, not keywords
const results = await brain.find({
query: "JavaScript"
})
// Returns all three - they're semantically related!
Graph Relationships Deep Dive
Graph relationships let you model connections between entities. Unlike traditional foreign keys, these are first-class citizens with types, directions, and properties.
// Create entities
const ts = await brain.add({ data: "TypeScript" })
const js = await brain.add({ data: "JavaScript" })
const anders = await brain.add({ data: "Anders Hejlsberg" })
// Create relationships
await brain.relate({ from: ts, to: js, type: "extends" })
await brain.relate({ from: anders, to: ts, type: "created" })
// Find what TypeScript extends
const base = await brain.find({
connected: { from: ts, type: "extends" }
})
// Find who created TypeScript
const creator = await brain.find({
connected: { to: ts, type: "created" }
})
Metadata Filtering Deep Dive
Metadata filtering uses readable, human-friendly operators for structured queries. This is perfect for filtering by dates, categories, numbers, or any structured attribute.
// Add entities with metadata
await brain.add({
data: "TypeScript 5.0 release notes",
metadata: {
type: "release",
version: 5.0,
year: 2023,
tags: ["typescript", "major"]
}
})
// Query with operators
const results = await brain.find({
where: {
type: "release", // Exact match
version: { greaterThanOrEqual: 4.0 }, // Greater than or equal
year: { oneOf: [2022, 2023] }, // In array
tags: { contains: "major" } // Array contains
}
})
Supported Operators
| Operator | Description | Example |
|---|---|---|
equals |
Equals (default) | { status: "active" } |
notEquals |
Not equals | { status: { notEquals: "deleted" } } |
greaterThan, greaterThanOrEqual |
Greater than (or equal) | { year: { greaterThanOrEqual: 2020 } } |
lessThan, lessThanOrEqual |
Less than (or equal) | { price: { lessThan: 100 } } |
oneOf |
Value in array | { category: { oneOf: ["A", "B"] } } |
contains |
Array contains value | { tags: { contains: "featured" } } |
between |
Value in range | { year: { between: [2020, 2024] } } |
exists |
Field exists | { tags: { exists: true } } |
Performance
Triple Intelligence queries are optimized to minimize work. The query planner:
- Applies metadata filters first (fastest, reduces candidate set)
- Uses graph constraints to prune unconnected entities
- Only computes vector similarity on remaining candidates
Result: sub-10ms queries even on millions of entities.