NimbleSearch is a lightweight, flexible search index for small to medium-sized datasets. It uses TF-IDF and cosine similarity for text fields and exact matching for keyword fields, providing a balance between performance and simplicity.
- Easy-to-use API for indexing and searching documents
- Command-line interface for quick operations
- Support for both text and keyword fields
- Customizable TF-IDF vectorization
- Field boosting for fine-tuned relevance
- Keyword filtering for precise results
- Persistence support (save/load functionality)
- Incremental updates to the index
- Docker support for easy deployment
- Automatic documentation generation
You can install NimbleSearch using pip:
pip install nimble-search
Or clone the repository and install it locally:
git clone https://github.com/aelfarra/nimble-search.git
cd nimble-search
pip install -e .
from nimble_search import NimbleSearch
# Create an index
index = NimbleSearch(text_fields=['title', 'content'], keyword_fields=['category'])
# Add documents
docs = [
{'title': 'Python Programming', 'content': 'Python is a versatile programming language.', 'category': 'Programming'},
{'title': 'Data Science with Python', 'content': 'Python is widely used in data science.', 'category': 'Data Science'},
# ... more documents ...
]
index.fit(docs)
# Search
results = index.search('Python programming', filter_dict={'category': 'Programming'}, num_results=5)
for result in results:
print(f"Title: {result['title']}, Score: {result['score']}")
NimbleSearch provides a command-line interface for quick operations:
nimble-search create --index myindex.pkl --text-fields title content --keyword-fields category --documents docs.json
nimble-search search --index myindex.pkl --query "Python programming" --filters '{"category": "Programming"}' --num-results 5
nimble-search add --index myindex.pkl --document '{"title": "New Python Course", "content": "Learn Python today!", "category": "Education"}'
nimble-search remove --index myindex.pkl --document-id 2
To run NimbleSearch using Docker:
docker build -t nimble-search .
docker run -p 8080:80 nimble-search
Alternatively, you can use Docker Compose:
docker-compose up
To generate the documentation:
python setup.py build_docs
The generated documentation will be available in the docs/build/html directory.
To set up the development environment:
git clone https://github.com/elfarradev/nimble-search.git
cd nimble-search
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
pip install -r requirements.txt
pip install -r requirements.txt
python -m unittest discover tests
We welcome contributions to NimbleSearch! Please see our contributing guidelines for more details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
NimbleSearch is created and maintained by Ahmed Elfarra ([email protected]).