ISSUE: SORT By on referenced field with left joins...
# community-help
a
ISSUE: SORT By on referenced field with left joins Hello everyone, i am encountering one issue related to "SORT By on referenced field with left joins". suppose i have users table and it has one to many relations with cars, but it is not necessary that cars records exists thats why i am using left joins to get records of users like this in filter by: '(id:* || $cars(id:* && $car_details(id:*)))' this is working fine . but when i am applying sort by "'$cars(created_at:desc)'" it says "{'results': [{'code': 400, 'error': 'No references found to sort by on cars.created_at.'}]}" this error is because some users doesnt have records in cars. same issue was posted here https://github.com/typesense/typesense/issues/2082 do you have any solution: my version: 27.1
k
We've made a bunch of join related fixed to the 0.28 RC builds. Can you please check against the latest build:
28.0.rc31
1
h
@Areeba Ayub I think
Copy code
$cars(id:* && $car_details(id:*))
part can be replaced with
Copy code
$cars($car_details(id:*))
a
Thankyou @Kishore Nallan @Harpreet Sangar for the response curl https://dl.typesense.org/releases/28.0.rc9/typesense-server-28.0.rc9-amd64.deb this version has solved my issue
k
That's a very old version of the RC build. You should use latest
28.0.rc31
a
ok thankyou
@Kishore Nallan @Kishore Nallan @Harpreet Sangar one quick question,
Copy code
filter_by: id:* || $cars(id:*)
it will get all the cars against users when i am sorting it like:
Copy code
"$cars(created_at:asc)
it says me {"status":400,"message":["Multiple references found to sort by on
cars.created_at
."], my query: i want to get user with car(only latest record)
m
I was wondering the same here. I have a collection of products and another of prices. Each product could have several prices. I'd like to know if I could sort those prices, but I'm receiving the same error above: "Multiple references found to sort by on `prices.value`" The other option would be doing the request directly from the prices collection joining the products collection and grouping by prices.product_id. The sorting works, but then I lost support for facets on the products collection because of this issue (https://github.com/typesense/typesense/issues/1706) :(
h
@Areeba Ayub @Matheus Bombonato Can you mention your use cases with a small dataset and expected result in this issue https://github.com/typesense/typesense/issues/1582
m
@Harpreet Sangar my use case is exactly the same as the original post. I've already give my thumbs up there. I'd just add that we need support for _eval usage too.
h
If possible, you should also mention minimal schema and a few docs with only the relevant fields and dummy values and the query you'd want to execute there.
m
ok. I'll do
h
Thanks 🙌🏼