Adam Wattis
1 min readApr 6, 2018

--

Very nice Jim Simon!

In addition to allowing searchable_fields to be explicitly defined on the Django model you might also include indexing all fields on a model by default. You can get the fields of a model and their internal type with:

fields = model._meta.fields
for field in fields:
print(field.name)
print(field.get_internal_type())

You’d need a function that translates the fields internal type to ES types. This could be done with an if statement in a separate function. That way you’d achieve a smarter solution that automatically maps each field with correct type.

--

--