A fast inverted-index search engine with native PDF tokenization — phrase, boolean, and ranked queries out of the box.
- Positional inverted index (term → docId → posting list)
- Phrase search, boolean AND/OR, TF-IDF ranked search
- PDF tokenization (MuPDF) with stop-word filtering
- pybind11 Python bindings (
fluxmodule) - Django backend with PDF.js viewer
struct Token { std::string text; uint32_t position, pageNo; bool isStopWord; };
struct Posting { uint32_t position, pageNo; };
struct PhraseHit{ uint32_t docId, position, pageNo; };
struct DocScore { uint32_t docId; double score; };| Method | Description |
|---|---|
addDocument(docId, tokens) |
Index a document's tokens |
removeDocument(docId) |
Remove a document from the index |
getPosting(word) |
Get postings for a term |
addDocPath(docId, path) |
Store file path for a document |
getDocCount() |
Number of indexed documents |
phraseSearch(terms) |
Match consecutive terms |
andSearch(terms) |
Docs containing all terms |
orSearch(terms) |
Docs containing any term |
rankedPhraseSearch(terms) |
Phrase match with TF-IDF scoring |
rankedAndSearch(terms) |
Boolean AND with TF-IDF scoring |
rankedOrSearch(terms) |
Boolean OR with TF-IDF scoring |
cmake -B build -S .
cmake --build build
ctest --test-dir build --output-on-failureC++17 · CMake ≥ 3.23 · Python ≥ 3.13
| Library | Purpose |
|---|---|
| MuPDF | PDF parsing |
| pybind11 | C++/Python bindings |
| GoogleTest | C++ unit testing |
| Django ≥ 6.0 | Web backend |
Python: django >= 6.0.5, django-environ >= 0.14.0, pybind11 >= 3.0.4
CMakeLists.txt
engine/
├── include/ indexer.hpp, tokenizer.hpp, persist.hpp
├── src/ indexer.cpp, tokenizer.cpp, bindings.cpp, persist.cpp
└── tests/ indexer_test.cpp, tokenizer_test.cpp, test.pdf
config/ Django settings
apps/search/ engine.py, models.py, views.py, urls.py
templates/ HTML templates
static/ CSS, PDF.js viewer
media/ Uploaded documents
.github/ CI workflow