-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Fleet] Support dynamic_template mappings from object field #137772
Merged
nchaulet
merged 8 commits into
elastic:main
from
nchaulet:feature-dynamic-template-mappings
Aug 3, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3fad1e9
[Fleet] Support dynamic_template mappings from object field
nchaulet 7e6084c
Update snapshot
nchaulet 811e843
Fix empty properties
nchaulet d988ac5
Fix after review
nchaulet 6c8cb71
Update snapshot
nchaulet 54a6c4e
Merge branch 'main' into feature-dynamic-template-mappings
kibanamachine 4589dd9
Fix merge existing dynamic_templates
nchaulet 3be2c5e
Merge branch 'main' into feature-dynamic-template-mappings
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 83 additions & 17 deletions
100
...gins/fleet/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/mappings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { Field } from '../../fields/field'; | ||
|
||
const DEFAULT_SCALING_FACTOR = 1000; | ||
|
||
interface Properties { | ||
[key: string]: any; | ||
} | ||
|
||
export function getDefaultProperties(field: Field): Properties { | ||
const properties: Properties = {}; | ||
|
||
if (field.index !== undefined) { | ||
properties.index = field.index; | ||
} | ||
if (field.doc_values !== undefined) { | ||
properties.doc_values = field.doc_values; | ||
} | ||
if (field.copy_to) { | ||
properties.copy_to = field.copy_to; | ||
} | ||
|
||
return properties; | ||
} | ||
|
||
export function scaledFloat(field: Field): Properties { | ||
const fieldProps = getDefaultProperties(field); | ||
fieldProps.type = 'scaled_float'; | ||
fieldProps.scaling_factor = field.scaling_factor || DEFAULT_SCALING_FACTOR; | ||
if (field.metric_type) { | ||
fieldProps.time_series_metric = field.metric_type; | ||
} | ||
|
||
return fieldProps; | ||
} | ||
|
||
export function histogram(field: Field): Properties { | ||
const fieldProps = getDefaultProperties(field); | ||
fieldProps.type = 'histogram'; | ||
|
||
return fieldProps; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created that file to start moving mapping generation to his own module.