Keyword Search Explained
Content: Keyword Search Explained
User Intent
Operation
How Keyword Search Works
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { ContentTypes, SearchTypes } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Pure keyword search
const results = await graphlit.queryContents({
search: "Project Alpha status report",
searchType: SearchTypes.Keyword,
limit: 10
});
console.log(`Found ${results.contents.results.length} keyword matches`);
results.contents.results.forEach((content, index) => {
console.log(`\n${index + 1}. ${content.name}`);
console.log(` Relevance: ${content.relevance}`);
console.log(` Type: ${content.type}`);
});
// Search for exact phrase
const exactPhrase = await graphlit.queryContents({
search: '"quarterly earnings report"', // Quotes = exact phrase
searchType: SearchTypes.Keyword
});
// Search for ID or code
const byId = await graphlit.queryContents({
search: "PROJ-1234",
searchType: SearchTypes.Keyword
});
// Search for email address
const byEmail = await graphlit.queryContents({
search: "[email protected]",
searchType: SearchTypes.Keyword
});
// Search for specific name
const byName = await graphlit.queryContents({
search: "Kirk Marple",
searchType: SearchTypes.Keyword
});Keyword Search Features
1. Token-Based Matching
2. Exact Phrase Search
3. Boolean Operators (if supported)
4. Case-Insensitive
5. Stemming
When to Use Keyword Search
Performance Characteristics
BM25 Ranking
Keyword search (snake_case)
Exact phrase
Search by ID
Developer Hints
Exact Phrase vs Token Search
Special Characters
Combining with Filters
Variations
1. Basic Keyword Search
2. Exact Phrase Search
3. Search by ID
4. Search by Email
5. Search with Content Type Filter
6. Search in Specific Collection
7. Multi-Term Search
Common Issues & Solutions
Production Example
Last updated