Skip to content

Commit

Permalink
[Fleet] Fix source mode synthetics when handling experimental datastr…
Browse files Browse the repository at this point in the history
…eam features (elastic#210195)
  • Loading branch information
nchaulet authored Feb 10, 2025
1 parent ff5e4fa commit d2070ca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ describe('experimental_datastream_features', () => {
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({ _source: { mode: 'synthetic' } }),
settings: expect.objectContaining({
index: expect.objectContaining({
mapping: expect.objectContaining({ source: { mode: 'synthetic' } }),
}),
}),
}),
}),
_meta: { has_experimental_data_stream_indexing_features: true },
Expand Down Expand Up @@ -483,7 +487,11 @@ describe('experimental_datastream_features', () => {
expect.objectContaining({
body: expect.objectContaining({
template: expect.objectContaining({
mappings: expect.objectContaining({ _source: { mode: 'synthetic' } }),
settings: expect.objectContaining({
index: expect.objectContaining({
mapping: expect.objectContaining({ source: { mode: 'synthetic' } }),
}),
}),
}),
}),
_meta: { has_experimental_data_stream_indexing_features: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,32 @@ export async function handleExperimentalDatastreamFeatureOptIn({
});

if (isSyntheticSourceOptInChanged) {
sourceModeSettings = {
_source: {
...(featureMapEntry.features.synthetic_source ? { mode: 'synthetic' } : {}),
},
};
sourceModeSettings = featureMapEntry.features.synthetic_source
? {
source: {
mode: 'synthetic',
},
}
: {};
}

if (componentTemplateChanged) {
const body = {
template: {
...componentTemplate.template,
settings: {
...componentTemplate.template?.settings,
index: {
...componentTemplate.template?.settings?.index,
mapping: {
...componentTemplate.template?.settings?.index?.mapping,
...sourceModeSettings,
},
},
},
mappings: {
...mappings,
properties: mappingsProperties ?? {},
...sourceModeSettings,
},
},
};
Expand Down

0 comments on commit d2070ca

Please sign in to comment.