[discover] respect the sample size settings when not sorting #4084
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For some time now discover has been sending the sort parameter in a new format. It was previously being read by the segmented fetch mechanism, but when the format changed the segmented fetch code was not updated. This causes more than the the configured sample size to show up in the table when sorted by timestamp.
update: To reproduce simply open discover in a fresh state, update your time filter to span multiple indices and a search result that contains more than 500 hits, and then scroll to the bottom of the results list. The "this is only 500 results" warning will be missing, the "size" param for each request should be set to 500, and there should be 500*nIndices rows visible
To fix this, the I added
SegmentedHandle#setSize()
. This method sets the number of hits that the segemented fetch will try to collect. As hits come back from elasticsearch, they are subtracted from this count and the next request will have a size parameter equal to the desired size minus the hits of the previous response.When sorting by anything other than time we must request the total size from each index and re-sort hits clientside. To enable this, either don't call
SegmentedHandle#setSize()
or passfalse
.