Package: esdocs
This is a modern replacement ofdjango-simple-elasticsearch(DSE). Both Django
and Elasticsearch have seen major changes over the years; this is a move to keep up.Why not just update django-simple-elasticsearch?DSE is Django-specific; I wanted to build a solution that could be used in a broader scope of applicationsTo start fresh and avoid assumptions made in the DSE projectDropped support for Python 2DetailsFlexible and modular; eg. Django support is available via a 'contrib' moduleSupports multi-process indexing and asynchronous IO viageventDepends on elasticsearch-dsl-py rather than the low level elasticsearch-py packageYou get a lot of functionality for free!Python 3 onlyesdocs >= 0.6 supports Elasticsearch 7.xInstallationpip install esdocsIf multi-process indexing is desired, you will want to install it along with the necessarygeventdependencies:pip install esdocs[gevent]Command Line Usage$ esdocs -h
usage: esdocs [-h] [-v] [--version] [--no_input] [--indexes INDEXES]
              [--using USING] [--multi [MULTI]]
              {list,init,update,rebuild,cleanup} ...

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         increase output verbosity
  --version             show program's version number and exit
  --no_input, --noinput
                        Do not prompt for user input (assumes 'Yes' for
                        actions)
  --indexes INDEXES     Comma-separate list of index names to target
  --using USING         Elasticsearch named connection to use
  --multi [MULTI]       Enable multiple processes and optionally set number of
                        CPU cores to use (defaults to all cores)

commands:
  {list,init,update,rebuild,cleanup}
    list                List indexes
    init                Initialize indexes
    update              Update indexes
    rebuild             Rebuild indexes
    cleanup             Delete unaliased indexesTo rebuild indexes specified by document serializers inESDOCS_SERIALIZER_MODULES:export ESDOCS_SERIALIZER_MODULES="mypackage.module1,myotherpackage.module2"
export ESDOCS_SERIALIZER_COMPATIBILITY_HOOKS="esdocs.contrib.postgresql.compatibility.range_field"

esdocs rebuildMulti-process indexing:export ESDOCS_GEVENT=y
export ESDOCS_SERIALIZER_MODULES="mypackage.module1,myotherpackage.module2"
export ESDOCS_SERIALIZER_COMPATIBILITY_HOOKS="esdocs.contrib.postgresql.compatibility.range_field"

# auto detect number of CPU cores to use
esdocs rebuild --multiproc

# specify the number of cores to use
esdocs rebuild --multiproc --numprocs=4DjangoYou must specifyESDOCS_SERIALIZER_MODULESin your Django settings and addesdocs.contrib.esdjangoto yourINSTALLED_APPS. You can optionally setESDOCS_SERIALIZER_COMPATIBILITY_HOOKSas well:INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    ...,
    'esdocs.contrib.esdjango'
]


ESDOCS_SERIALIZER_MODULES = [
    'mypackage.module1',
    'myotherpackage.module2'
]

# these are the current defaults for this setting
ESDOCS_SERIALIZER_COMPATIBILITY_HOOKS = [
    'esdocs.contrib.esdjango.compatibility.manager',
    'esdocs.contrib.esdjango.compatibility.geosgeometry',
    'esdocs.contrib.postgresql.compatibility.range_field'
]Serializing DataFor esdocs to work, you need to defineDocumentandSerializer(orDjangoSerializer) subclasses to index
your data.Documentcomes from the excellent elasticsearch-dsl-py, whileSerializer/DjangoSerializerare
a part of esdocs.Documentdefines the Elasticsearch field mappingsSerializeris associated with aDocumentSerializerdefines how to retrieve the datasetFor each record in your dataset, theSerializerwill attempt to retrieve a value for each field defined on the associatedDocumentThere are a number of methods you can implement on aSerializerto retrieve (or construct/munge) each valueExamples