I am creating a website for social interaction on a specific topic, based on flows, I think about gmail, only public. There will also be some kind of static information in dictionaries, as well as in a blog, directories, knowledge base, etc. This is django + postgres.
One of the most important requirements is a full-text search of all information, regardless of the type of model. If an exact search phrase appears on a blog, and her distorted sister in the messages, than a fragment from a blog entry, must first appear in the search results, and a message fragment should appear behind it. So, I need a table with all indexed texts and links to _any_other_table_ in db.
My first idea is to create a separate model with a “free link”, for example:
class Content(models.Model): obj_id= CharField() # An id of the object of a given model. model= CharField(choices=("Message", "BlogEntry", "HowTo", "EntityProfile",)) content_type= CharField(choices=("subject", "body", "description", "tags",)) body= TextField()
But it doesn’t feel right ... This promises an extra hassle around link integrity when creating and re-linking instances.
So the question is, is there an elegant solution that django will provide? What could be the most efficient architecture to solve the problem?
I do not ask for a direct answer, but rather a hint.
Thanks in advance!