Skip to main content

lf rag

Query your knowledge base and access RAG maintenance utilities.

Querying Documents

lf rag query "question" [flags]
FlagPurpose
--databaseSelect a database (defaults to config default).
--data-processing-strategyFilter results to a strategy.
--retrieval-strategyOverride retrieval behaviour (vector, hybrid, metadata filtered, etc.).
--top-kNumber of chunks to return.
--score-thresholdMinimum similarity score.
--filterApply metadata filters (key:value). Repeatable.
--include-metadata, --include-scoreShow metadata/score columns.
--distance-metric, --hybrid-alpha, --rerank-model, --query-expansion, --max-tokensAdvanced knobs matching server capabilities.

Example:

lf rag query --database main_db --filter "doc_type:letter" --include-metadata \
"Which letters mention additional clinical trials?"

Maintenance Commands

Some subcommands are hidden from --help but available for operators:

CommandDescription
lf rag statsVector/document counts, storage usage (JSON or table).
lf rag healthEmbedder/store health summary.
lf rag listList ingested documents and metadata.
lf rag compactCompact/optimize the vector store.
lf rag reindexReindex all documents using a given strategy.
lf rag clearDelete all documents from a database (dangerous).
lf rag deleteRemove documents by ID, filename, or metadata filter.
lf rag export/importMove datasets between environments.

⚠️ Destructive commands (clear, delete) prompt for confirmation unless you pass --force.

Troubleshooting

  • Empty results – confirm dataset processing succeeded and the retrieval strategy matches your query type.
  • Timeouts – large datasets can take time to process; check Celery logs or increase --server-start-timeout before retrying.
  • Hybrid/Tool Errors – some smaller models don’t support tool calls; switch to a basic agent handler via configuration.

See Also