Skip to content

Amarifields/search-engine-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

search-engine-lite

A fast, single-binary CLI that indexes a text file and lets you search it with ranked results. Designed for quick grepping with smarter scoring.

Features

  • Indexes a plain text file into an in-memory inverted index
  • Case-insensitive by default, optional case-sensitive matching
  • AND/OR query modes
  • Ranked results with frequency and proximity scoring
  • Top-N limiting
  • Interactive REPL mode
  • Compact output suitable for scripting

Installation

Requirements: Rust 1.70+.

cargo build --release

The binary will be at target/release/search-engine-lite.

On Windows PowerShell, you can run the binary directly:

./target/release/search-engine-lite --file .\README.md --search rust

Usage

search-engine-lite --file ./notes.txt --search "rust indexing"
search-engine-lite --file ./notes.txt --search "pipeline" --mode or --limit 20
search-engine-lite --file ./notes.txt --interactive
search-engine-lite --file ./notes.txt --stats

Options

  • --file <PATH>: Input text file to index (required)
  • --search <QUERY>: One-off query string
  • --mode <and|or>: Matching mode (default: and)
  • --limit <N>: Max results to print (default: 10)
  • --case-sensitive: Enable case-sensitive tokenization
  • --interactive: Start an interactive prompt
  • --stats: Print index stats and top frequent terms

Output

Each result prints: line_number score line_text Example:

42 3.125 Building a compact inverted index in Rust

Examples

  • Quick lookup:
search-engine-lite --file ./README.md --search "inverted index"
  • Browse interactively:
search-engine-lite --file ./README.md --interactive --limit 5

Performance notes

  • Streaming read with a compact in-memory map
  • Simple tokenizer tuned for ASCII and common punctuation
  • Proximity scoring favors lines where query terms appear closer together

Development

cargo run -- --file ./README.md --search rust
cargo test

License

MIT

About

command line search utility that indexes text files and retrieves matching words.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages