FILTER_BUILDER
BUILD_FILTER
LIVE_PREVIEW
READY
OPERATOR_REFERENCE
=, !=
Equality comparison
>, <, >=, <=
Numeric comparison
AND, OR
Logical operators
NOT
Negation
IN [...]
Array membership
ANY [...]
Array contains any
EXAMPLE_GALLERY
LIVE_SANDBOX
Vectors: 0
Filter: --
Results: --
Time: --
Enter a filter expression and click SEARCH to see results
CODE_SNIPPETS
// Initialize EdgeVec
import init, { EdgeVec, EdgeVecConfig } from 'edgevec';
await init();
const config = new EdgeVecConfig(768);
const db = new EdgeVec(config);
// Insert vectors with metadata
const vector = new Float32Array(768).fill(0.1);
db.insertWithMetadata(vector, {
category: "electronics",
price: 299.99,
inStock: true
});
// Search with filter (simplified API)
const query = new Float32Array(768).fill(0.1);
const results = db.searchWithFilter(
query,
'category = "electronics" AND price < 500',
10
);
console.log(results); // [{id, distance}, ...]
import init, { EdgeVec, EdgeVecConfig } from 'edgevec';
interface ProductMetadata {
category: string;
price: number;
inStock: boolean;
}
async function searchProducts(): Promise<void> {
await init();
const config = new EdgeVecConfig(768);
const db: EdgeVec = new EdgeVec(config);
// Insert with typed metadata
const metadata: ProductMetadata = {
category: "electronics",
price: 299.99,
inStock: true
};
const vector = new Float32Array(768).fill(0.1);
db.insertWithMetadata(vector, metadata);
// Filtered search (simplified API)
const filter = 'category = "electronics" AND price < 500';
const results = db.searchWithFilter(vector, filter, 10);
}
import { useState, useEffect } from 'react';
import init, { EdgeVec, EdgeVecConfig } from 'edgevec';
function useEdgeVec(dimensions: number) {
const [db, setDb] = useState<EdgeVec | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function initialize() {
await init();
const config = new EdgeVecConfig(dimensions);
setDb(new EdgeVec(config));
setLoading(false);
}
initialize();
}, [dimensions]);
return { db, loading };
}
function ProductSearch() {
const { db, loading } = useEdgeVec(768);
const [filter, setFilter] = useState('');
const [results, setResults] = useState([]);
const handleSearch = () => {
if (!db) return;
const query = new Float32Array(768).fill(0.1);
const res = db.searchWithFilter(query, filter, 10);
setResults(res);
};
return (
<div>
<input value={filter} onChange={e => setFilter(e.target.value)} />
<button onClick={handleSearch}>Search</button>
</div>
);
}