Skip to content

patw/AtlasBadSearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AtlasBadSearch

MongoDB Text Search Implementation without using Atlas Search or $text

This is an educational implementation of a simple text search engine using MongoDB, FastAPI, and NLTK. It demonstrates basic concepts of text indexing and search but is not suitable for production use.

⚠️ Important Disclaimer

This project is for educational purposes only. It is not:

  • A production-ready search solution
  • Optimized for performance or scale
  • Secure enough for real-world use
  • A replacement for dedicated search technologies

Use only for learning about basic search concepts.

Features

  • Basic document indexing with term frequency counting
  • Simple search functionality
  • Stemming and stopword removal using NLTK
  • Bulk document indexing

Setup

  1. Clone the repository:
git clone https://github.com/patw/atlasbadsearch.git
cd mongodb-text-search
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file with your MongoDB connection string:
echo "MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority" > .env
echo "MONGODB_DBNAME=search_db" >> .env
  1. Run the FastAPI server:
uvicorn app.main:app --reload

API Endpoints

  • POST /index - Index a single document
  • POST /bulk_index - Index multiple documents at once
  • GET /search - Search documents by query terms

Example Usage

Index a document:

curl -X POST "http://localhost:8000/index" \
-H "Content-Type: application/json" \
-d '{"text":"This is an example document to index"}'

Bulk index documents from file:

curl -X POST "http://localhost:8000/bulk_index" \
-H "Content-Type: application/json" \
-d @sample_bulk.txt

Search documents:

curl "http://localhost:8000/search?query=example document"

Educational Concepts Demonstrated

  • Tokenization and stemming
  • Stopword removal
  • Term frequency counting
  • Basic search scoring
  • MongoDB document structure for search

License

MIT License - See LICENSE for details.

About

Implementation of search on Mongo without Atlas Search or $text. It's terrible.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages