Skip to main content

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

You can define indices using two different styles:

Style 1: Tuple-based field definitions

from django_manticoresearch import ManticoreIndex, TextField, BigintField, index_registry
from myapp.models import Post

@index_registry.register
class PostIndex(ManticoreIndex):
    _index_name = "posts"
    model = Post
    
    fields = (
        TextField("title"),
        TextField("content"),
        BigintField("views"),
    )
    
    # Optional field weights for relevance scoring
    field_weights = {
        "title": 10,
        "content": 5,
    }

Style 2: Class attribute field definitions

from django_manticoresearch import ManticoreIndex, CharField, IntegerField, BooleanField
from myapp.models import Post

class PostIndex(ManticoreIndex):
    title = CharField()
    content = CharField()
    views = IntegerField()
    is_published = BooleanField(default=False)
    
    class Meta:
        index_name = 'posts'
        model = Post

Field Definitions

The following field types are available for defining index fields:

class PostIndex(ManticoreIndex):
    # Field definition in the fields tuple
    fields = (
        # Text fields for full-text search
        TextField("title"),
        TextField("content"),
        
        # Numeric fields
        IntegerField("category_id"),
        BigintField("views"),
        
        # Boolean field
        BooleanField("is_published"),
        
        # Date/time field
        DateTimeField("publication_date"),
        
        # String field (for exact match, not full-text)
        StringField("slug"),
        
        # Multi-value array field
        MVAField("tags"),
    )

Auto-Discovery of Indices

By default, django-manticoresearch automatically discovers and registers indices from all installed apps. The package looks for index definitions in these files:

  1. <app_name>/indexes.py
  2. <app_name>/indices.py

To use auto-discovery:

  1. Create one of these files in your Django app
  2. Define your ManticoreIndex classes in that file
  3. No manual registration is needed

Example app structure:

myapp/
  ├── models.py
  ├── views.py
  └── indexes.py  # Your ManticoreIndex definitions go here

You can disable auto-discovery by setting MANTICORE_AUTO_REGISTER_MODELS to False in your Django settings:

MANTICORE_AUTO_REGISTER_MODELS = False  # Default is True

If you disable auto-discovery, you'll need to manually register your indices:

from django_manticoresearch import index_registry

@index_registry.register
class MyIndex(ManticoreIndex):
    # Your index definition...

Searching

# 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 indexing

Create indices for a specific app:

python manage.py indexing --app=myapp

Create indices and index all objects:

python manage.py indexing --reindex

Drop existing indices before creating:

python manage.py indexing --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

Release files for django-manticoresearch 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-manticoresearch 0.3.2
File Size Uploaded
django_manticoresearch-0.3.2.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-manticoresearch 0.3.2
File Interpreter ABI Platform
django_manticoresearch-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 32.3 kB

Release files / django_manticoresearch-0.3.2.tar.gz

Download URL django_manticoresearch-0.3.2.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8cc05051c6a35fe3638d6c89cbf8f95a1545acbd7c52d0224de9678310fd324f
BLAKE2b-256 checksum
How to use checksums
b256c170669ffe1bf1d9d35e7145a7cfbd0a813f4d504f6ec0b8b811bdc3b4c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / django_manticoresearch-0.3.2-py3-none-any.whl

Download URL django_manticoresearch-0.3.2-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3115b5c174e7707223f0b9d2f1538fc27b275ef639732051b464167839c94557
BLAKE2b-256 checksum
How to use checksums
1d17b89c3b3457714fb2e442672ff591f6dfa66848b96151447f7947a991eee8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page