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.

Javascript developer. Passionate learner.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store