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
I've confirmed that the results come back in the proper order from elasticsearch by visually inspecting the results like this: Model.search.map(&:score). However, when I call .records on the results, the scores get jumbled, and I have to re-sort them manually in ruby.
It looks like you can call a mongoid scope method like order(sort: :desc) on the object records returns to get the proper order, but the .to_a method doesn't seem to be working for some reason.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Confirmed also with 8.7.0, calling results returns the records in the proper order, while calling records does not match up or appear to apply any ordering. We are simply attempting to use the default ranking by _score.
The mongoid integration has the same sorting bug as documented in #546 and others. The records. I'm using elasticsearch-model 7.0.
I have a field in my mapping called
score
(separate from the elasticsearch_score
). I'm running a search query like this:I've confirmed that the results come back in the proper order from elasticsearch by visually inspecting the results like this:
Model.search.map(&:score)
. However, when I call.records
on the results, the scores get jumbled, and I have to re-sort them manually in ruby.I see that there's some code trying to solve this here, because mongoid doesn't return results in id order: https://github.com/elastic/elasticsearch-rails/blob/v7.0.0/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb#L40.
It looks like you can call a mongoid scope method like
order(sort: :desc)
on the object records returns to get the proper order, but the.to_a
method doesn't seem to be working for some reason.The text was updated successfully, but these errors were encountered: