You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the search model...when user searches for both comments and stories we search for results using multisearch (rather than pg_scope).
Multisearch dosen't return the actual records (Collection of Comment and Story objects) but rather PgSearch::Document objects.
This object has a polymorphic association to searchable ( results.first.searchable ) which yields the actual record (story or comment).
Since we wan't to sort on properties of search results' searchable associated object, the db query will need to use joins to eager load searchable object and then use order to sort on thi associatd object's property (created_at, upvotes etc ).
pg_search's multisarch has issue with joins ( eager load doesn't work).
Also order dosen't work and we have to use reorder but reorder doesn't seem to have a documented way of ordering by associated object attributes.
Temporarily using sort_by on fetched results.
The text was updated successfully, but these errors were encountered:
In the search model...when user searches for both comments and stories we search for results using multisearch (rather than pg_scope).
Multisearch dosen't return the actual records (Collection of Comment and Story objects) but rather
PgSearch::Document
objects.This object has a polymorphic association to
searchable
( results.first.searchable ) which yields the actual record (story or comment).Since we wan't to sort on properties of search results' searchable associated object, the db query will need to use
joins
to eager load searchable object and then useorder
to sort on thi associatd object's property (created_at, upvotes etc ).pg_search's multisarch has issue with
joins
( eager load doesn't work).Also
order
dosen't work and we have to usereorder
but reorder doesn't seem to have a documented way of ordering by associated object attributes.Temporarily using
sort_by
on fetched results.The text was updated successfully, but these errors were encountered: