# Path: seeker/registry.py
# def register(doc_class, app_label=None):


from django.conf import settings
from django.utils.encoding import force_text
from elasticsearch import NotFoundError
from elasticsearch_dsl.connections import connections
from .registry import model_documents
    from django.contrib.contenttypes.models import ContentType
    from django.contrib.contenttypes.models import ContentType
import elasticsearch_dsl as dsl
import importlib
import sys
import time
    return getattr(mod, class_name)


def index(obj, index=None, using=None):
    """
    Shortcut to index a Django object based on it's model class.
    """
    model_class = ContentType.objects.get_for_model(obj).model_class()
    for doc_class in model_documents.get(model_class, []):
        if not doc_class.queryset().filter(pk=obj.pk).exists():
            continue
        doc_using = using or doc_class._doc_type.using or 'default'
        doc_index = index or doc_class._doc_type.index or getattr(settings, 'SEEKER_INDEX', 'seeker')
        es = connections.get_connection(doc_using)
        body = doc_class.serialize(obj)
        doc_id = body.pop('_id', None)
        es.index(
            index=doc_index,
            doc_type=doc_class._doc_type.name,
            body=body,
            id=doc_id,
            refresh=True
        )


def delete(obj, index=None, using=None):
    """
    Shortcut to delete a Django object from the ES index based on it's model class.
    """
    model_class = ContentType.objects.get_for_model(obj).model_class()

# Path: seeker/registry.py
# def register(doc_class, app_label=None):


# Path: seeker/utils.py
from django.conf import settings
from django.utils.encoding import force_text
from elasticsearch import NotFoundError
from elasticsearch_dsl.connections import connections
from .registry import model_documents
    from django.contrib.contenttypes.models import ContentType
    from django.contrib.contenttypes.models import ContentType
import elasticsearch_dsl as dsl
import importlib
import sys
import time

    return getattr(mod, class_name)


def index(obj, index=None, using=None):
    """
    Shortcut to index a Django object based on it's model class.
    """
    model_class = ContentType.objects.get_for_model(obj).model_class()
    for doc_class in model_documents.get(model_class, []):
        if not doc_class.queryset().filter(pk=obj.pk).exists():
            continue
        doc_using = using or doc_class._doc_type.using or 'default'
        doc_index = index or doc_class._doc_type.index or getattr(settings, 'SEEKER_INDEX', 'seeker')
        es = connections.get_connection(doc_using)
        body = doc_class.serialize(obj)
        doc_id = body.pop('_id', None)
        es.index(
            index=doc_index,
            doc_type=doc_class._doc_type.name,
            body=body,
            id=doc_id,
            refresh=True
        )


def delete(obj, index=None, using=None):
    """
    Shortcut to delete a Django object from the ES index based on it's model class.
    """
    model_class = ContentType.objects.get_for_model(obj).model_class()

    for doc_class in model_documents.get(model_class, []):