Django integration for Manticore Search
Project description
Django Manticoresearch
Django integration for Manticore Search engine.
Installation
pip install django-manticoresearch
Configuration
Add django_manticoresearch to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
# ...
'django_manticoresearch',
# ...
]
Configure Manticore connection settings:
MANTICORE_SCHEMA = "http"
MANTICORE_HOST = "localhost"
MANTICORE_PORT = 9308
Basic Usage
Define Indices (Legacy API)
This style uses class attributes for field definitions and a Meta class for configuration. This is fully supported for backward compatibility.
from django_manticoresearch import ManticoreIndex, CharField, IntegerField
class PostIndex(ManticoreIndex):
title = CharField()
content = CharField()
views = IntegerField()
class Meta:
index_name = 'posts'
model = YourModel # Optional, can also be set during initialization
Define Indices (New Advanced API)
The new style uses a more explicit approach with fields defined as a tuple:
from django_manticoresearch import BaseManticoreIndex, TextField, BigintField, index_registry
from myapp.models import Post
@index_registry.register
class PostIndex(BaseManticoreIndex):
_index_name = "posts"
model = Post
fields = (
TextField("title"),
TextField("content"),
BigintField("views"),
)
# Optional field weights for relevance scoring
field_weights = {
"title": 10,
"content": 5,
}
Searching with Different APIs
Legacy API
# Class method approach
results = PostIndex.search("query text")
# Convert to Django queryset
queryset = PostIndex.model.objects.filter(id__in=[hit["_id"] for hit in results])
New API
# Initialize the index
index = PostIndex()
# Basic search
results = index.search("query text")
# Advanced search with options
results = index.search(
query="query text",
match_fields=["title", "content"],
enable_wildcard_search=True,
infix_search=True
)
# Convert results to Django QuerySet
queryset = index.search_result_to_queryset(results)
Auto-Indexing
The package automatically connects signals to update indices when model instances are created, updated, or deleted.
Management Commands
Create all indices:
python manage.py manticore_setup_indexes
Create indices for a specific app:
python manage.py manticore_setup_indexes --app=myapp
Create indices and index all objects:
python manage.py manticore_setup_indexes --reindex
Drop existing indices before creating:
python manage.py manticore_setup_indexes --recreate
Features
- Django ORM-like interface for Manticore search
- Advanced search with wildcards, prefix, infix and full-text search
- Automatic index management with Django signals
- Field type validation and transformation
- Rich query builder API
- Highlighting support
- Support for complex data structures
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_manticoresearch-0.1.0.tar.gz.
File metadata
- Download URL: django_manticoresearch-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b02928048a64a5c4d9e8cc20ad9fb7d0d11d9299d39e8f44afe55f82f772d05e
|
|
| MD5 |
3b42b9700d5fcf5c47dcba7a7de11567
|
|
| BLAKE2b-256 |
37e97d90d83554f64efa7a2f9147ba474c776738d7c4918b7fc46d4f41302ed4
|
File details
Details for the file django_manticoresearch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_manticoresearch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
357c527d16bece4a96a405f2196948c13e84d3f362b5857fd8edd3d3b351cef1
|
|
| MD5 |
f2450194d84fcca93b54425d7286a366
|
|
| BLAKE2b-256 |
3e00385f7d879c2e9e3b9cd67c1daaed8f1ac96eca1d266c8e877b5f1ea38cfc
|