Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -473,14 +473,12 @@ describe('Alerts Service', () => {
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
name: existingIndexTemplate.name,
body: {
...existingIndexTemplate.index_template,
template: {
...existingIndexTemplate.index_template.template,
settings: {
...existingIndexTemplate.index_template.template?.settings,
'index.mapping.total_fields.limit': 2500,
},
...existingIndexTemplate.index_template,
template: {
...existingIndexTemplate.index_template.template,
settings: {
...existingIndexTemplate.index_template.template?.settings,
'index.mapping.total_fields.limit': 2500,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ const updateUnderlyingMapping = async ({

try {
await retryTransientEsErrors(
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
() => esClient.indices.putMapping({ index, body: simulatedMapping }),
() => esClient.indices.putMapping({ index, ...simulatedMapping }),
{ logger }
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,12 @@ describe('createOrUpdateComponentTemplate', () => {
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
name: existingIndexTemplate.name,
body: {
...existingIndexTemplate.index_template,
template: {
...existingIndexTemplate.index_template.template,
settings: {
...existingIndexTemplate.index_template.template?.settings,
'index.mapping.total_fields.limit': 2500,
},
...existingIndexTemplate.index_template,
template: {
...existingIndexTemplate.index_template.template,
settings: {
...existingIndexTemplate.index_template.template?.settings,
'index.mapping.total_fields.limit': 2500,
},
},
});
Expand Down Expand Up @@ -283,14 +281,12 @@ describe('createOrUpdateComponentTemplate', () => {
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledTimes(1);
expect(clusterClient.indices.putIndexTemplate).toHaveBeenCalledWith({
name: existingIndexTemplate.name,
body: {
...existingIndexTemplate.index_template,
template: {
...existingIndexTemplate.index_template.template,
settings: {
...existingIndexTemplate.index_template.template?.settings,
'index.mapping.total_fields.limit': 2500,
},
...existingIndexTemplate.index_template,
template: {
...existingIndexTemplate.index_template.template,
settings: {
...existingIndexTemplate.index_template.template?.settings,
'index.mapping.total_fields.limit': 2500,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ const getIndexTemplatesUsingComponentTemplate = async (
() =>
esClient.indices.putIndexTemplate({
name: template.name,
body: {
...template.index_template,
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
template: {
...template.index_template.template,
settings: {
...template.index_template.template?.settings,
'index.mapping.total_fields.limit': totalFieldsLimit,
},
...template.index_template,
template: {
...template.index_template.template,
settings: {
...template.index_template.template?.settings,
'index.mapping.total_fields.limit': totalFieldsLimit,
},
},
// GET brings string | string[] | undefined but this PUT expects string[]
ignore_missing_component_templates: template.index_template
.ignore_missing_component_templates
? [template.index_template.ignore_missing_component_templates].flat()
: undefined,
}),
{ logger }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,11 @@ describe('setLegacyIndexTemplateToHidden', () => {
await clusterClientAdapter.setLegacyIndexTemplateToHidden('foo-bar-template', currentTemplate);
expect(clusterClient.indices.putTemplate).toHaveBeenCalledWith({
name: 'foo-bar-template',
body: {
order: 0,
index_patterns: ['foo-bar-*'],
settings: { index: { number_of_shards: '1' }, 'index.hidden': true },
mappings: { dynamic: false, properties: {} },
aliases: {},
},
order: 0,
index_patterns: ['foo-bar-*'],
settings: { index: { number_of_shards: '1' }, 'index.hidden': true },
mappings: { dynamic: false, properties: {} },
aliases: {},
});
});

Expand Down Expand Up @@ -659,7 +657,8 @@ describe('updateConcreteIndices', () => {
});
expect(clusterClient.indices.putMapping).toHaveBeenCalledWith({
index: 'foo',
body: { dynamic: false, properties: { '@timestamp': { type: 'date' } } },
dynamic: false,
properties: { '@timestamp': { type: 'date' } },
});
});

Expand Down Expand Up @@ -720,7 +719,8 @@ describe('updateConcreteIndices', () => {

expect(clusterClient.indices.putMapping).toHaveBeenCalledWith({
index: 'foo',
body: { dynamic: false, properties: { '@timestamp': { type: 'date' } } },
dynamic: false,
properties: { '@timestamp': { type: 'date' } },
});
expect(logger.error).toHaveBeenCalledWith(
`Error updating index mappings for foo: failed to put mappings`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,10 @@ export class ClusterClientAdapter<
const esClient = await this.elasticsearchClientPromise;
await esClient.indices.putTemplate({
name: indexTemplateName,
body: {
...currentIndexTemplate,
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
settings: {
...currentIndexTemplate.settings,
'index.hidden': true,
},
...currentIndexTemplate,
settings: {
...currentIndexTemplate.settings,
'index.hidden': true,
},
});
} catch (err) {
Expand Down Expand Up @@ -461,8 +458,7 @@ export class ClusterClientAdapter<
const simulatedMapping = get(simulatedIndexMapping, ['template', 'mappings']);

if (simulatedMapping != null) {
// @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584
await esClient.indices.putMapping({ index: name, body: simulatedMapping });
await esClient.indices.putMapping({ index: name, ...simulatedMapping });
this.logger.debug(`Successfully updated concrete index mappings for ${name}`);
}
} catch (err) {
Expand Down
34 changes: 17 additions & 17 deletions x-pack/platform/plugins/shared/task_manager/server/task_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,24 +902,24 @@ export class TaskStore {
{ max_docs: max_docs }: UpdateByQueryOpts = {}
): Promise<UpdateByQueryResult> {
const { query } = ensureQueryOnlyReturnsTaskObjects(opts);
const { sort, ...rest } = opts;
try {
const // @ts-expect-error [email protected] https://github.com/elastic/elasticsearch-js/issues/2584 types complain because the body should not be there.
// However, we can't use this API without the body because it fails to claim the tasks.
// eslint-disable-next-line @typescript-eslint/naming-convention
{ total, updated, version_conflicts } = await this.esClientWithoutRetries.updateByQuery(
{
index: this.index,
ignore_unavailable: true,
refresh: true,
conflicts: 'proceed',
body: {
...opts,
max_docs,
query,
},
},
{ requestTimeout: this.requestTimeouts.update_by_query }
);
// eslint-disable-next-line @typescript-eslint/naming-convention
const { total, updated, version_conflicts } = await this.esClientWithoutRetries.updateByQuery(
{
index: this.index,
ignore_unavailable: true,
refresh: true,
conflicts: 'proceed',
...rest,
max_docs,
query,
// @ts-expect-error According to the docs, sort should be a comma-separated list of fields and goes in the querystring.
// However, this one is using a "body" format?
body: { sort },
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this saying we're formatting the sort wrong or this function is expecting the sort in the body field?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll let @JoshMock and @pquentin confirm.
But based on the documentation, body sort is not supported by ES. Although the fact that ES doesn't 400 these requests makes me think that's a "hidden feature".

},
{ requestTimeout: this.requestTimeouts.update_by_query }
);

const conflictsCorrectedForContinuation = correctVersionConflictsForContinuation(
updated,
Expand Down