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

fix: keep sort in search hit as is #1576

Open
wants to merge 1 commit into
base: release-branch.v7
Choose a base branch
from

Conversation

houz42
Copy link

@houz42 houz42 commented Jan 27, 2022

'sort' in search hit should be kept as is.

In some cases, when search documents while sort by an int64 field (date_nano for example), server returns a sort value in each hit, which contains a long number. If we represent sort as []interface{}, the long number will be treated as float64 by std json decoder, and if the number is great enough (and date_nano value of tody is great enough), we will get an incorrect int64 value in go.

And when the incorrect sort value is used for next search reqeuest (set as search_after parameter), we may see duplicated or missing documents in pagingated search requests.

To keep backward compatable, I did not remove or change the type of Sort field in SearchHit, but add a new field RawSort as []json.RawMessage and json unmarshaller instread.

@houz42
Copy link
Author

houz42 commented Jan 27, 2022

@olivere I have found an issue on search request and proposed a quick fix, may you be available to have a look? thanks.

@olivere
Copy link
Owner

olivere commented Mar 19, 2022

I don't like to deprecate the Sort field like that, but I see your point.

@RaphaelL2e
Copy link

I think can replcae json.unmarshal to json.decoder

@RaphaelL2e
Copy link

@houz42 Ask a question, I used this mr but the order is still wrong.

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

Successfully merging this pull request may close these issues.

None yet

3 participants