What does this error relate to ```RequestMalformed...
# community-help
s
What does this error relate to
Copy code
RequestMalformed: Request failed with HTTP code 400 | Server said: Multiple references found to sort by on `userFood.dateLastUsed`.
Previously the query worked before updating to v27
As soon as we have results to return that now gets thrown (doesnt happen if there are no results found)
@Kishore Nallan
Seems maybe is this? Previously we had
"filter_by": "$userFood(userId:RrLJVnXTyIRLGTNlp6rZB89hqQ03) && $userFood(addedToMeals:Breakfast)",
Where we had to put each join collection separately. If I change to this
"filter_by": "$userFood(userId:RrLJVnXTyIRLGTNlp6rZB89hqQ03 && addedToMeals:Breakfast)",
Seems to work (ie multiple references of X). As you now support
$joinCollection(condition)
in the syntax it seems?
k
@Harpreet Sangar
👀 1
h
"filter_by": "$userFood(userId:RrLJVnXTyIRLGTNlp6rZB89hqQ03 && addedToMeals:Breakfast)",
was always supported.
Copy code
Multiple references found to sort by on `userFood.dateLastUsed`.
This error message is returned when a particular doc has multiple references to the joined collection. For example:
Orders.product_ids
references
Products.id
, you cannot specify
Products
field in
sort_by
like:
Copy code
collection: Orders
q: *
filter_by: $Products(id: *)
sort_by: $Products(price:desc)
because we cannot decide the sort order using product prices since multiple products are related to an order.
You can specify your use case here https://github.com/typesense/typesense/issues/1582
s
"`"filter_by": "$userFood(userId:RrLJVnXTyIRLGTNlp6rZB89hqQ03 && addedToMeals:Breakfast)",` was always supported." - I dont think so - as the syntax we had was proposed from your end like
"filter_by": "$userFood(userId:RrLJVnXTyIRLGTNlp6rZB89hqQ03) && $userFood(addedToMeals:Breakfast)",
, has been this way in our code since ages ago - before there was even documentation and we just suggested in Slack the way to accomplish our use case and has remained. In any case, changing to
$userFood(userId:RrLJVnXTyIRLGTNlp6rZB89hqQ03 && addedToMeals:Breakfast)
stopped that error
h
Can you confirm if
"filter_by": "$userFood(addedToMeals:Breakfast)"
produces the error?
s
yeah
Copy code
{
  "q": "pizza",
  "query_by": "name",
  "filter_by": "$userFood(userId:OFSDzvSFkNOQ2Y0psX50b9ngdZG3 && addedToMeals:Breakfast)",
  "include_fields": "$foodBrands(name) as foodBrand, $portionSizes(name) as portionSize, $userFood(count, dateLastUsed, addedToMeals)",
  "sort_by": "$userFood(dateLastUsed:desc)"
}
is good
but if we have this (which up until 27~ was good)
Copy code
{
  "q": "pizza",
  "query_by": "name",
  "filter_by": "$userFood(userId:OFSDzvSFkNOQ2Y0psX50b9ngdZG3) && $userFood(addedToMeals:Breakfast)",
  "include_fields": "$foodBrands(name) as foodBrand, $portionSizes(name) as portionSize, $userFood(count, dateLastUsed, addedToMeals)",
  "sort_by": "$userFood(dateLastUsed:desc)"
}
We get
Copy code
RequestMalformed: Request failed with HTTP code 400 | Server said: Multiple references found to sort by on `userFood.dateLastUsed`.
h
Okay. I'll look into it. Also, I suggest you check other queries. The join condition of a particular collection should be mentioned in
$joinCollection(condition)
format.
s
Thanks
yep we are reviewing others for this
How’d you go reviewing that ? @Harpreet Sangar
k
We've a fix for this one already. Will be part of the other pagination/limits fix.
❤️ 1
s
Amazing
I also wrote above some (not all) of our use cases for union
HTH