I'm using PostgreSQL's Full Text Search in Django.
My data is stored in a tree structure, like so:
- note 100 #This is a tree
- note 341
- note 422
- note 101 #This is another tree
- note 218
- note 106
In the database, each note is just an individual row with a link to its parent:
id | note_body | parent_id
-----------------------------
341 | "foo" | 100
422 | "bar" | 341
...
This makes it possible to retrieve a single tree (i.e. several individual notes) at once.
My question is: How can I use full text where each document is a whole tree, rather than a single note?
In this example, searching for "foo"
or "bar"
should return note 100, which is the root of the tree that contains that word.
I would like to do this using Django's full text search API.