Skip to content
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

Allow indexing fields from related models #1

Closed
zgoda opened this issue May 25, 2017 · 3 comments
Closed

Allow indexing fields from related models #1

zgoda opened this issue May 25, 2017 · 3 comments

Comments

@zgoda
Copy link
Contributor

zgoda commented May 25, 2017

I have 2 models related by foreign key and I would like to search data from related model, eg Author and Book so I could search for both author name and book title. I can create artificial field that concatenates all fields I want to have searchable but this is inconvenient.

This could be like eg:

class Book(db.Model):
    __searchable__ = ['title', 'summary', 'author.full_name']

where author is db.relationship based on foreign key

@honmaple
Copy link
Owner

Thank you for your support,at present flask-msearch doesn't support relationship column,I will add it in the future.

@zgoda
Copy link
Contributor Author

zgoda commented May 25, 2017

Okay, I'm working on a PR that would allow some workaround using SQLAlchemy hybrid_property. Basically one change to _schema() method to detect that this is not a "normal" field.

@honmaple
Copy link
Owner

Related models has been added on fe4544f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants