Hi all. I have a question on including fields fro...
# community-help
s
Hi all. I have a question on including fields from joined collections. When I reference a joined collection with include_fields, can I be selective about what from that second collection is returned without impacting the main collection results? Something like: &include_fields=$catalogs(name,user_id:= user_a) would return the related catalog.name that was for user_a, but not restrict products that had no catalog reference for user_a. If I use filter_by I only get back documents from the main collection that are related to matched records in the joined collection. But can I accomplish above where I get back all matches from the main collection, but augmented with only certain matches from the joined collection? Here is the background: I have a primary collection (products) with a document for each product. In our system, users can create catalogs of products, and these catalogs can be shared to other users. I'd like a user's search results to have a facet with any catalogs they have access to for the products in their search results. Products and catalogs have a many to many relationship. I have all the catalogs a product is part of on the product document. My thought was another collection (catalogs) joined on those catalog IDs with the details of each catalog (like which users can see it).
Actually, I think I got it. I needed to put the reference on catalog, and use the left join approach. &filter_by=id:* || $test_catalog_collection( users:=[3]) Using that when querying the products seems to give me all product matches, but only adds in the specified include_fields from the catalog collection if it has user 3.
And now I see that you can't facet by fields related to joined collections.
j
Yup, we're actively working on supporting facet_by for fields coming from joined collections
s
Is there a card in the road map for it? It isn't going to be v.28 is it? There are several other JOIN cards slated for 28 we're waiting on.
f
Our Roadmap is available on GitHub under Projects -> Typesense Public Roadmap ⚑ πŸ” πŸ›£οΈ πŸ—ΊοΈ πŸš€ : https://github.com/orgs/typesense/projects/1 You can keep track of any feature requests that are open there. Querying by a joined collection's fields is going to be in
v28
, and we're still working on faceting by those fields
s
@Fanis Tharropoulos I can't find a card for faceting by related fields on joined collections. Or is that covered by this issue? https://github.com/typesense/typesense/issues/1657
j