Skip to main content

Overview

The index command processes all directories in the watch list, extracting text content, chunking it, and creating vector embeddings for semantic search.

Syntax

know index [OPTIONS]

Options

--log
boolean
default:"false"
Show detailed logs during indexing, including file processing information and statistics.Alias: -l
--ext
list[string]
default:"[supported extensions]"
Comma-separated list of file extensions to index. By default, indexes all supported file types.Alias: -eExample: --ext .md,.txt or --ext md,txt
--glob
list[string]
Include only files matching glob patterns. Can be specified multiple times or as comma-separated values.Alias: -gExample: --glob "**/*.md" --glob "notes/**"
--since
string
Only index files modified since the specified time. Accepts relative time (e.g., 7d, 12h, 30m) or absolute dates (e.g., 2024-01-15).Examples:
  • 7d - Last 7 days
  • 12h - Last 12 hours
  • 30m - Last 30 minutes
  • 2w - Last 2 weeks
  • 2024-01-15 - Since January 15, 2024
  • 2024-01-15T10:30:00 - Specific timestamp
--recursive
boolean
default:"true"
Scan subdirectories recursively. Use --no-recursive to scan only top-level files.Alias: -r (enable), -R (disable)
--chunk-size
integer
default:"512"
Size of each text chunk in tokens. Larger chunks provide more context but may reduce precision.Alias: -c
--overlap
integer
default:"50"
Number of overlapping tokens between consecutive chunks. Helps maintain context across chunk boundaries.Alias: -o
--force
boolean
default:"false"
Clear the entire index and re-index everything from scratch.Alias: -f
--dry
boolean
default:"false"
Simulate indexing without writing to the database. Useful for previewing what will be indexed.
--report
Path
Write a JSON report of skipped files to the specified path.

Examples

Basic indexing

know index
Indexing 2 directories
OK Total: 143 new, 89 unchanged

Index with detailed logs

know index --log
Indexing 1 directories
Extensions: ['.md', '.txt', '.py', ...]
Chunk size: 512, overlap: 50
──────────────────────── /home/user/docs ────────────────────────
✓ Processing notes.md (3 chunks)
✓ Processing readme.txt (1 chunk)
...
OK Total: 45 new, 12 unchanged

Index only markdown files

know index --ext .md

Index files modified in last 7 days

know index --since 7d
Indexing 2 directories
OK Total: 23 new, 0 unchanged

Index with glob patterns

know index --glob "**/*.md" --glob "docs/**"

Force re-index everything

know index --force
Indexing 2 directories
OK Total: 245 new, 0 unchanged

Dry run to preview indexing

know index --dry --log
Dry run: Scanning 2 directories
Extensions: ['.md', '.txt', '.py', ...]
...
Dry run: Would index 34 new, 102 unchanged

Custom chunk settings

know index --chunk-size 1024 --overlap 100

Generate skip report

know index --report skip-report.json
Indexing 2 directories
OK Total: 56 new, 189 unchanged
Report written to skip-report.json
The index command only processes files that have been modified since the last index. Use --force to rebuild the entire index from scratch.
Use --dry with --log to see exactly what files will be indexed before making any changes.
Using --force clears the entire index. Make sure this is what you want before running it.

Time Format Reference

The --since flag accepts flexible time formats:
FormatDescriptionExample
<N>mMinutes ago30m
<N>hHours ago12h
<N>dDays ago7d
<N>wWeeks ago2w
YYYY-MM-DDAbsolute date2024-01-15
ISO 8601Full timestamp2024-01-15T10:30:00

Prerequisites

Before running know index, you must:
  1. Add at least one directory: know add <directory>
  2. Verify directories are added: know dirs

See Also

  • know add - Add directories to watch list
  • know prune - Remove orphaned chunks
  • know search - Search indexed content

Build docs developers (and LLMs) love