-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested objects/relations #2
Milestone
Comments
+1 |
+1 |
Any ETA on this one? |
Same as the 2.0.0 milestone. |
What is the due date for 2.0.0? |
Is there a way to handle nested objects yet? |
@xiaolin @brendan-rius @adavanisanti @oliver-zhou: Hi there and sorry for the late reply. We don't have a current date for the 2.0.0 milestone as @dethi left the company. However, you can index relations by proxying an attribute in the index configuration: Modelsclass Account(models.Model):
username = models.CharField(max_length=40)
service = models.CharField(max_length=40)
class Contact(models.Model):
name = models.CharField(max_length=40)
email = models.EmailField(max_length=60)
//...
accounts = models.ManyToManyField(Account)
def account_names(self):
return [str(account) for account in self.accounts.all()]
def account_ids(self):
return [account.id for account in self.accounts.all()] Indexfrom algoliasearch_django import AlgoliaIndex
class ContactIndex(AlgoliaIndex):
fields = ('name', 'email', 'company', 'address', 'city', 'county',
'state', 'zip_code', 'phone', 'fax', 'web', 'followers', 'account_names', 'account_ids')
settings = {
'searchableAttributes': ['name', 'email', 'company', 'city', 'county', 'account_names',
}
|
side2k
referenced
this issue
in brightnetwork/algoliasearch-django
Feb 27, 2020
fixed code for use with python3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: