[Answered ]-How to indexes ImageField in django-elasticsearch-dsl

1๐Ÿ‘

โœ…

A FileFieldย [Django-doc] is essentially jus a CharFieldย [Django-doc] with some extra logic to wrap the data into a FieldFile that can then open, write, etc. on the file handler.

You thus can create a document with a TextField instead:

@registry.register_document
class BookDocument(Document):
    image = fields.TextField()

    class Index:
        name = 'books'
        settings = {'number_of_shards': 1, 'number_of_replicas': 0}

    class Django:
        model = Book

        fields = [
            'id',
            'title',
            'description',
        ]

Leave a comment