# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['django_es_drf', 'django_es_drf.drf', 'django_es_drf.drf.backends']

package_data = \
{'': ['*']}

install_requires = \
['django>=4,<5',
 'djangorestframework>=3.13.1,<4.0.0',
 'elasticsearch-dsl>=7,<8',
 'lazy-object-proxy>=1.7.1,<2.0.0',
 'luqum>=0.11.0,<0.12.0']

setup_kwargs = {
    'name': 'django-es-drf',
    'version': '1.0.0a1',
    'description': 'Simple django - elasticsearch - drf integration',
    'long_description': '# Django ES DRF\n\n**Work in progress**\n\nA simple integration layer between Django, Elasticsearch and Django rest framework\n\n## Model and ES Document example\n\nTo declare your own document, create a model and register it with\na DjangoDocument\n\n```python\nfrom django.db import models\nfrom django_es_drf import registry, DjangoDocument\nfrom rest_framework.serializers import ModelSerializer\n\n\nclass School(models.Model):\n    name = models.CharField(max_length=100)\n    address = models.TextField()\n\n\n@registry.register(School)\nclass SchoolDocument(DjangoDocument):\n    class Index:\n        name = "schools"\n```\n\nIf you want to split the file into models, serializers\nand documents, be free to do so but ensure that the \nfile including documents is loaded at the startup -\nin app\'s ready function, imported at the bottom of the\nmodel etc.\n\nLater on, use `SchoolDocument` (which is a subclass of elasticsearch-dsl document):\n\n```python\nfor s in SchoolDocument.search().filter(\'term\', name=\'Blah\'):\n    print(s)\n    s.name = s.name + \'-test\'\n    s.save()  # will save django and index to ES\n```\n\n## DRF example\n\nThe simplest case is:\n\n```python\n\nclass SchoolAPI(ESViewSet):\n    document = SchoolDocument\n```\n\n### Search, facets\n\n### Luqum search\n\n## Django Document and mapping\n\n### Custom declaration for fields\n\nAny fields that are already present on the document will be keep as they are. In the example above, to set that\n`name` is a `text` and not `keyword` (the default), just declare:\n\n```python\nimport elasticsearch_dsl as e\n\n\n@registry.register(School, SchoolSerializer)\nclass SchoolDocument(DjangoDocument):\n    name = e.Text()\n\n    class Index:\n        name = "schools"\n```\n\n### Excluding fields\n\nTo exclude a field from the automatic generation, add it to `excluded_fields`:\n\n```python\n@registry.register(School, SchoolSerializer,\n                   excluded_fields=[\'address\'])\nclass SchoolDocument(DjangoDocument):\n    class Index:\n        name = "schools"\n```\n\n### Custom mapping between serializer fields and ES fields\n\nAdd your own mapping - the key is the DRF field type, value is a function that takes the field and context and returns ES field:\nThe context is an instance of `RegistrationContext`.\n\n```python\nimport elasticsearch_dsl as e\n\n\n@registry.register(School, SchoolSerializer,\n                   mapping={\n                       TextField: lambda fld, ctx: e.Keyword()\n                   })\nclass SchoolDocument(DjangoDocument):\n    class Index:\n        name = "schools"\n```\n\n### Disabling the mapping\n\nAdd `generate=False` to decorator\'s parameters:\n\n```python\nimport elasticsearch_dsl as e\n\n\n@registry.register(School, SchoolSerializer,\n                   generate=False)\nclass SchoolDocument(DjangoDocument):\n    # you need to provide your own mapping here\n\n    class Index:\n        name = "schools"\n```\n\n### Relations\n\nThe framework does not generate code for relations -\nif you need this, do it in serializer and add your\nown mapping, or use a more complete library, such as\ndjango-elasticsearch-dsl-drf.\n\n## Serializer\n\nThe serializer is just a plain DRF serializer that converts\ndjango fields to document\'s fields. When autogenerated mapping\nis used, just use the plain empty serializer.\n\nNote: see Relations section above if you need to serialize\nrelations\n\n## Objects and nested\n\n## Viewsets',
    'author': 'Mirek Simek',
    'author_email': 'miroslav.simek@vscht.cz',
    'maintainer': None,
    'maintainer_email': None,
    'url': None,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.9,<4.0',
}


setup(**setup_kwargs)
