Skip to content

Commit

Permalink
Fixes elastic#6698 - ES no longer supports unmapped_type param on _sc…
Browse files Browse the repository at this point in the history
…ore field sorting
  • Loading branch information
Bargs committed Mar 30, 2016
1 parent b475997 commit 78ef309
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ngMock from 'ng_mock';
import expect from 'expect.js';
import NormalizeSortRequestProvider from 'ui/courier/data_source/_normalize_sort_request';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import _ from 'lodash';

describe('SearchSource#normalizeSortRequest', function () {
let normalizeSortRequest;
Expand Down Expand Up @@ -87,4 +88,17 @@ describe('SearchSource#normalizeSortRequest', function () {

expect(result).to.eql([normalizedSort]);
});

it('should remove unmapped_type parameter from _score sorting', function () {
var sortable = { _score: 'desc'};
var expected = [{
_score: {
order: 'desc'
}
}];

var result = normalizeSortRequest(sortable, indexPattern);
expect(_.isEqual(result, expected)).to.be.ok();

});
});
4 changes: 4 additions & 0 deletions src/ui/public/courier/data_source/_normalize_sort_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default function normalizeSortRequest(config) {
sortValue = { order: sortValue };
}
sortValue = _.defaults({}, sortValue, defaultSortOptions);

if (sortField === '_score') {
delete sortValue.unmapped_type;
}
}

normalized[sortField] = sortValue;
Expand Down

0 comments on commit 78ef309

Please sign in to comment.