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

How to select individual fields on records while keeping them sorted by _score? #903

Closed
TheCorp opened this issue Aug 20, 2019 · 2 comments
Labels

Comments

@TheCorp
Copy link

TheCorp commented Aug 20, 2019

I have a simple model and a search query that is returning results sorted correctly.

Model.search("search").records <- sorted correctly

How do I then use ActiveRecord select() to only pull certain fields on the model records returned? An Elasticsearch response records enumerator doesn't respond to the select() method that a normal ActiveRecord::Relation would.

I see that I can do Model.search("search").records.records.select('some_field') to select the fields correctly because the 2nd .records is an ActiveRecord::Relation but....

Model.search("search").records.records <-- not sorted correctly!

Is there some other way of approaching this that I am missing or is it just not appropriate to select less than the full list of fields when returning sorted records via an ES search?

@TheCorp TheCorp changed the title How to select individual fields on records? How to select individual fields on records while keeping them sorted by _score? Aug 20, 2019
@TheCorp
Copy link
Author

TheCorp commented Aug 20, 2019

Btw I looked closely at this issue before posting and it doesn't seem to be related to the issue I am having - #546

@stale
Copy link

stale bot commented Aug 31, 2020

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.

@stale stale bot added the stale label Aug 31, 2020
@stale stale bot closed this as completed Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant