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

sort by score doesn't seem to work && Add _score, max_score in the response #54

Open
nbittich opened this issue Sep 18, 2022 · 2 comments

Comments

@nbittich
Copy link
Contributor

it would be very handy to have information about the search results from elastic in the response (e.g in the meta object or something like this).

In this example, we would need the max_score to show it as the first row, then order the other hits by the _score (desc):

image

also, I've tried to sort data based on the score (sort[:avg:score]=desc) and that doesn't seem to work.

@nvdk
Copy link
Member

nvdk commented Oct 27, 2022

I think sorting on avg score doesn't make much sense and I wonder where the example in the readme is coming for. I think sort[_score]=desc should work though, so perhaps we should just update the readme for that?

Including _score and max_score makes sense, I think we just need to add track_scoring when sorting is enabled. See also https://www.elastic.co/guide/en/elasticsearch/reference/current/sort-search-results.html#_track_scores

@nbittich
Copy link
Contributor Author

In the case described in the design above, we search over positions based on the person's firstname and/or lastname, and then we group these positions in the frontend based on the person's id linked to it. a person can have multiple position.
Since we group them in a map of person=>positions in the frontend, we lose the sorting and thus, if we had the score, it would be much easier to sort them back in the frontend.

Let me know if it's unclear. A possible workaround would be to index the person, search on the persons, then search again on the position, and somehow merge both in the grouping i mentioned before. but this seem a bit more work for the frontend & more data to index / keep in sync

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

No branches or pull requests

2 participants