Skip to content

Commit abf2f38

Browse files
lukeelmerskibanamachine
authored andcommitted
[core.savedObjects] Remove _shard_doc tiebreaker since ES now adds it automatically. (#92295)
1 parent 56391db commit abf2f38

File tree

4 files changed

+3
-40
lines changed

4 files changed

+3
-40
lines changed

src/core/server/saved_objects/service/lib/search_dsl/search_dsl.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ describe('getSearchDsl', () => {
9696
mappings,
9797
opts.type,
9898
opts.sortField,
99-
opts.sortOrder,
100-
opts.pit
99+
opts.sortOrder
101100
);
102101
});
103102

src/core/server/saved_objects/service/lib/search_dsl/search_dsl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function getSearchDsl(
7878
hasReferenceOperator,
7979
kueryNode,
8080
}),
81-
...getSortingParams(mappings, type, sortField, sortOrder, pit),
81+
...getSortingParams(mappings, type, sortField, sortOrder),
8282
...(pit ? getPitParams(pit) : {}),
8383
...(searchAfter ? { search_after: searchAfter } : {}),
8484
};

src/core/server/saved_objects/service/lib/search_dsl/sorting_params.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ describe('searchDsl/getSortParams', () => {
7979
],
8080
});
8181
});
82-
it('appends tiebreaker when PIT is provided', () => {
83-
expect(getSortingParams(MAPPINGS, 'saved', 'title', undefined, { id: 'abc' }).sort).toEqual(
84-
expect.arrayContaining([{ _shard_doc: 'asc' }])
85-
);
86-
});
8782
});
8883
describe('sortField is simple root property with multiple types', () => {
8984
it('returns correct params', () => {
@@ -98,11 +93,6 @@ describe('searchDsl/getSortParams', () => {
9893
],
9994
});
10095
});
101-
it('appends tiebreaker when PIT is provided', () => {
102-
expect(
103-
getSortingParams(MAPPINGS, ['saved', 'pending'], 'type', undefined, { id: 'abc' }).sort
104-
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
105-
});
10696
});
10797
describe('sortField is simple non-root property with multiple types', () => {
10898
it('returns correct params', () => {
@@ -124,11 +114,6 @@ describe('searchDsl/getSortParams', () => {
124114
],
125115
});
126116
});
127-
it('appends tiebreaker when PIT is provided', () => {
128-
expect(
129-
getSortingParams(MAPPINGS, 'saved', 'title.raw', undefined, { id: 'abc' }).sort
130-
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
131-
});
132117
});
133118
describe('sortField is multi-field with single type as array', () => {
134119
it('returns correct params', () => {
@@ -143,11 +128,6 @@ describe('searchDsl/getSortParams', () => {
143128
],
144129
});
145130
});
146-
it('appends tiebreaker when PIT is provided', () => {
147-
expect(
148-
getSortingParams(MAPPINGS, ['saved'], 'title.raw', undefined, { id: 'abc' }).sort
149-
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
150-
});
151131
});
152132
describe('sortField is root multi-field with multiple types', () => {
153133
it('returns correct params', () => {
@@ -162,12 +142,6 @@ describe('searchDsl/getSortParams', () => {
162142
],
163143
});
164144
});
165-
it('appends tiebreaker when PIT is provided', () => {
166-
expect(
167-
getSortingParams(MAPPINGS, ['saved', 'pending'], 'type.raw', undefined, { id: 'abc' })
168-
.sort
169-
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
170-
});
171145
});
172146
describe('sortField is not-root multi-field with multiple types', () => {
173147
it('returns correct params', () => {

src/core/server/saved_objects/service/lib/search_dsl/sorting_params.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,14 @@
88

99
import Boom from '@hapi/boom';
1010
import { getProperty, IndexMapping } from '../../../mappings';
11-
import { SavedObjectsPitParams } from '../../../types';
12-
13-
// TODO: The plan is for ES to automatically add this tiebreaker when
14-
// using PIT. We should remove this logic once that is resolved.
15-
// https://github.com/elastic/elasticsearch/issues/56828
16-
const ES_PROVIDED_TIEBREAKER = { _shard_doc: 'asc' };
1711

1812
const TOP_LEVEL_FIELDS = ['_id', '_score'];
1913

2014
export function getSortingParams(
2115
mappings: IndexMapping,
2216
type: string | string[],
2317
sortField?: string,
24-
sortOrder?: string,
25-
pit?: SavedObjectsPitParams
18+
sortOrder?: string
2619
) {
2720
if (!sortField) {
2821
return {};
@@ -38,7 +31,6 @@ export function getSortingParams(
3831
order: sortOrder,
3932
},
4033
},
41-
...(pit ? [ES_PROVIDED_TIEBREAKER] : []),
4234
],
4335
};
4436
}
@@ -59,7 +51,6 @@ export function getSortingParams(
5951
unmapped_type: rootField.type,
6052
},
6153
},
62-
...(pit ? [ES_PROVIDED_TIEBREAKER] : []),
6354
],
6455
};
6556
}
@@ -84,7 +75,6 @@ export function getSortingParams(
8475
unmapped_type: field.type,
8576
},
8677
},
87-
...(pit ? [ES_PROVIDED_TIEBREAKER] : []),
8878
],
8979
};
9080
}

0 commit comments

Comments
 (0)