Skip to content
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

[EPM] Handle object type fields with properties in mappings #64745

Merged
merged 2 commits into from
Apr 29, 2020

Conversation

skh
Copy link
Contributor

@skh skh commented Apr 29, 2020

Summary

This fixes a problem in the mapping generation for fields of type object with additional properties.

A field definition of

- name: a
  type: object
- name: a.b
  type: keyword

now generates a mapping of the form

properties: {
      a: {
        properties: {
          b: {
            ignore_above: 1024,
            type: 'keyword',
          },
        },
      },
    },

Before this change, the field a.b did not get correctly deduped and nested under field a.

Thanks to @jonathan-buttner for the analysis!

How to test this

  • Inspect the added test cases. Is this the desired behaviour?
  • Installation of packages should work as before.

@skh skh added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project v7.8.0 Team:Fleet Team label for Observability Data Collection Fleet team labels Apr 29, 2020
@skh skh requested a review from a team April 29, 2020 06:26
@skh skh self-assigned this Apr 29, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

Copy link
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

LGTM. I'm good with merging the PR as it fixes the existing issue. Left two minor comments.

@@ -108,7 +108,15 @@ function dedupFields(fields: Fields): Fields {
return f.name === field.name;
});
if (found) {
if (found.type === 'group' && field.type === 'group' && found.fields && field.fields) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a comment in here that explains why this code is needed (to cover the a, a.b problem).

@@ -179,4 +179,35 @@ describe('processFields', () => {
JSON.stringify(mixedFieldsExpanded)
);
});

const objectFieldWithProperty = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it also work if you have a.b first and then a?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I've added a unit test for that.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

I checked it out and tested it. Looks good! Thanks for the quick change @skh !

@skh skh merged commit 2c7741b into elastic:master Apr 29, 2020
skh added a commit to skh/kibana that referenced this pull request Apr 29, 2020
…64745)

* Generate correct mapping for object type field with properties

* Add test for fields definition in reverse order
skh added a commit that referenced this pull request Apr 29, 2020
…64774)

* Generate correct mapping for object type field with properties

* Add test for fields definition in reverse order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants