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 #4466

Merged
merged 6 commits into from
Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define(function (require) {
// export a couple methods from the request
this.setDirection = _.bindKey(req, 'setDirection');
this.setSize = _.bindKey(req, 'setSize');
this.setMaxSegments = _.bindKey(req, 'setMaxSegments');
}

return SegmentedHandle;
Expand Down
9 changes: 9 additions & 0 deletions src/kibana/components/courier/fetch/request/segmented.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ define(function (require) {
** SegmentedReq specific methods
*********/

/**
* Set the sort total number of segments to emit
*
* @param {number}
*/
SegmentedReq.prototype.setMaxSegments = function (maxSegments) {
this._maxSegments = _.parseInt(maxSegments);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had a rule in jshint about adding base 10 to parseInt. In any event, you should do it.

Also, what happens when we set _maxSegments to 0?

};

/**
* Set the sort direction for the request.
*
Expand Down
2 changes: 2 additions & 0 deletions src/kibana/plugins/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ define(function (require) {
*/
var sortBy = (function () {
if (!_.isArray(sort)) return 'implicit';
else if (sort[0] === '_score') return 'implicit';
else if (sort[0] === timeField) return 'time';
else return 'non-time';
}());
Expand All @@ -331,6 +332,7 @@ define(function (require) {
}

$scope.updateTime();
if (sort[0] === '_score') segmented.setMaxSegments(1);
segmented.setDirection(sortBy === 'time' ? (sort[1] || 'desc') : 'desc');
segmented.setSize(sortBy === 'time' ? $scope.opts.sampleSize : false);

Expand Down