This project provides a lightweight, extensible backend for product search using Django and OpenSearch. It supports tag-based filtering, free-text search, and future-ready support for semantic vector search (e.g., via CLIP or custom embeddings).
- Django (Models, Admin, API logic)
- Django REST Framework (Search endpoint)
- OpenSearch (Indexed search + filters)
- Redis (optional) for caching
- Celery (optional) for async indexing
- Docker (recommended) for local dev
- Index products with
name,description,tags, and optionaltag_vector - Search by:
- Free-text query (across name & description)
- Filter by one or more tags
- Built-in support for AI-generated tags (via
ProductTagmodel andtag_vector) - Simple REST endpoint for search
git clone https://github.com/your-user/django-opensearch-search.git
cd django-opensearch-search
# Setup virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Start OpenSearch (use Docker or local setup)
docker-compose up -d opensearch
# Run Django
python manage.py migrate
python manage.py runserver
Defines the Product, Tag, and ProductTag models with support for tag metadata and JSON vectors.
Handles indexing of Product objects to OpenSearch, including tag names and tag vectors.
Exposes a REST API endpoint (GET /search) to:
- Search by keyword
- Filter by tags
- Return matching product documents from OpenSearch
GET /search?tags=shoes&tags=green&q=summerReturns all products matching the term summer in name/description AND tagged with both shoes and green.
- Cosine similarity vector search (CLIP integration)
- Faceted filtering (categories, brands, price ranges)
- Real-time updates via Celery tasks
- OpenAPI/Swagger auto-docs
- Use OpenSearch's
textfields for full-text queries - Use
keywordfields for tag filters - Define custom analyzers for fuzzy matching, synonyms, or edge n-grams if needed
- Store
tag_vectoras dense vectors to enable semantic search in the future
Pull requests and feature suggestions are welcome! Feel free to fork and build on top of this to suit your own product catalog or tagging system.
MIT — Use freely, launch fast, and remember to re-index responsibly 😉