Query with Filters
User Intent
"I want to search and filter my ingested content by various criteria"
Operation
SDK Method:
graphlit.queryContents()GraphQL:
queryContentsqueryEntity Type: Content
Common Use Cases: Semantic search, filter by type/date/collection, faceted search, similarity search
TypeScript (Canonical)
import { Graphlit } from 'graphlit-client';
import { ContentTypes, EntityState, FileTypes, ObservableTypes, SearchTypes } from 'graphlit-client/dist/generated/graphql-types';
const graphlit = new Graphlit();
// Basic search - returns all content
const response = await graphlit.queryContents({});
console.log(`Found ${response.contents.results.length} content items`);
// Text search with semantic similarity
const searchResponse = await graphlit.queryContents({
search: 'machine learning best practices',
searchType: SearchTypes.Hybrid, // Combines keyword + vector search
limit: 10
});
console.log(`Search found ${searchResponse.contents.results.length} results`);
// Filter by content type
const pdfResponse = await graphlit.queryContents({
types: [ContentTypes.File],
fileTypes: [FileTypes.Pdf],
limit: 20
});
console.log(`Found ${pdfResponse.contents.results.length} PDF files`);Parameters
ContentFilter Options
Search:
search(string): Search query textUses semantic similarity (embeddings)
Supports natural language queries
searchType(SearchTypes): Search strategyKEYWORD- Traditional keyword matchingVECTOR- Semantic/embedding searchHYBRID- Combined keyword + vector (recommended)
Content Type Filters:
types(ContentTypes[]): Filter by content typeFILE,PAGE,TEXT,MEMORY,EMAIL,MESSAGE,POST,ISSUE,EVENT
fileTypes(FileTypes[]): Filter by file type (when type = FILE)PDF,DOCX,IMAGE,AUDIO,VIDEO,MARKDOWN, etc.
textTypes(TextTypes[]): Filter text contentPLAIN,MARKDOWN
Temporal Filters:
creationDateRange(DateRangeFilter): Filter by creation datefrom(Date): Start dateto(Date): End date
modifiedDateRange(DateRangeFilter): Filter by modification date
Organization Filters:
collections(EntityReferenceFilter[]): Filter by collection membershipfeeds(EntityReferenceFilter[]): Filter by source feedworkflows(EntityReferenceFilter[]): Filter by workflow used
State Filters:
states(EntityState[]): Filter by processing stateENABLED,DISABLED,FINISHED,ERROR,AWAITING_EXTRACTION
Advanced Filters:
similarContents(EntityReferenceInput[]): Find similar contentobservations(ObservationFilter): Filter by extracted entities
Pagination & Sorting:
offset(number): Skip first N results (default: 0)limit(number): Max results to return (default: 10, max: 100)orderBy(OrderByTypes): Sort fieldRELEVANCE- By search relevance score (when search is used)CREATION_DATE- By creation dateNAME- Alphabetically by name
orderDirection(OrderDirectionTypes): Sort directionASC- AscendingDESC- Descending (default)
Response
Developer Hints
Search Type Selection
When to use each search type:
KEYWORD
Exact term matching, technical terms
Traditional text matching
VECTOR
Semantic/conceptual search, natural language
Embedding similarity
HYBRID
Most searches (recommended)
Combines both approaches
OrderBy Behavior
Understanding Relevance Scores
Pagination Best Practices
Variations
1. Filter by Date Range
Find content created in a specific time period:
2. Filter by Collection
Search within specific collections:
3. Filter by Multiple Content Types
Search across specific content types:
4. Similarity Search
Find content similar to existing content:
5. Filter by State
Find content in specific processing states:
6. Filter by Feed Source
Find content from specific feeds:
7. Complex Filter Combination
Combine multiple filters:
8. Filter by Extracted Entities
Find content mentioning specific entities:
Common Issues
Issue: Search returns no results even though content exists
Solution: Check that content has finished processing (state: FINISHED). Embeddings must be generated for vector search.
Issue: Relevance scores seem low (< 0.5)
Solution: This is normal. Relevance is relative. Use HYBRID search type for better results.
Issue: orderBy: RELEVANCE but results not sorted by relevance
Solution: Relevance ordering only works when search parameter is provided. Without search, use CREATION_DATE or NAME.
Issue: Getting duplicate results across pages
Solution: Ensure consistent orderBy and orderDirection across pagination requests. Content may shift if new items are added during pagination.
Issue: Pagination returns fewer results than limit
Solution: You've reached the end of results. This is expected behavior.
Production Example
Parallel query with count:
Last updated
Was this helpful?