Hi Everyone! I am trying to get my head around JO...
# community-help
r
Hi Everyone! I am trying to get my head around JOINs. In particular concerning the "One-to-many relation". Lets say I have a collection
books
and a collection
authors
. In the
books
collection the author is referenced via id like so
{"name": "author_id", "type": "string", "reference": "authors.id"}
. What I would like to do is when I search lets say for all authors starting with the name "Frank", I also want to include the books of each author in the documents returned from Typesense. Is this possible via the right value for the
filter_by
parameter or is this not possible without knowing the ID of the author as stated in the example
"filter_by":"$orders(customer_id:=customer_a)"
. Thanks for your help.
j
If you're searching on author name and want to include a list of books, you want to set up a book_ids field in the authors collection and join that to the books collection. Then you you'd use the
q: frank
and then use
include_fields
to include all books joined to that author
r
And in this case the
book_ids
field is an array of strings?
h
@Robert Weber Yes.
{"name": "book_ids", "type": "string[]", "reference": "books.id"}
👍 1
r
@Jason Bosco @Harpreet Sangar Tested it. Works like a charm party parrot
🙌🏼 1
🙌 1