Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't order pg_search multisearch results in query itself #15

Open
sidevesh opened this issue Aug 18, 2016 · 1 comment
Open

Can't order pg_search multisearch results in query itself #15

sidevesh opened this issue Aug 18, 2016 · 1 comment
Assignees

Comments

@sidevesh
Copy link

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.

@sidevesh sidevesh assigned raghavio and sandys and unassigned raghavio and sandys Aug 18, 2016
@sidevesh
Copy link
Author

sidevesh commented Aug 18, 2016

Commit which comments out multisearch: 07b509b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants