I'm using elasticsearch_dsl to help with interfacing with elasticsearch and this is the model I currently have and I'm trying to recreate as a DocType:
class HouseIndex(DocType):
house_type = String()
#people
sold = Boolean()
built_datetime = Date()
#alerts
# associated_locations
hash = String()
class House(models.Model):
house_type = models.ForeignKey(HouseType, db_index=True,
on_delete=models.CASCADE)
people = models.ManyToManyField(to='Person', db_index=True,
through='PersonToHouseMap')
sold = models.BooleanField(default=False)
built_datetime = models.DateTimeField()
alerts = models.ManyToManyField(Alert)
associated_locations = models.ManyToManyField(to='Location')
hash = models.CharField(max_length=64, unique=True, null=True)
objects = HouseManager()
But I'm not sure what to do when it's a ManyToMany field. Such as with people, alerts, and associated locations.
It really depends on what you wish to query for, but I'd probably use a Nested field containing a list of the Location objects. You can see something similar in my example repo here - https://github.com/HonzaKral/es-django-example/blob/master/qa/models.py#L48
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With