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

Add multi field info to the IndexPattern #33681

Merged
merged 9 commits into from
Apr 2, 2019
Merged

Conversation

Bargs
Copy link
Contributor

@Bargs Bargs commented Mar 21, 2019

Summary

Fixes #31921
Related to #7419

Adds two fields to the IndexPattern Field:

  • parent - the name of the field this field is a child of
  • subType - The type of child this field is. Currently the only valid value is multi but we could expand this to include aliases, object children, and nested children.

The thinking behind implementing these two new properties instead of a simple isMultiField flag is that it should be generic enough to describe other sorts of parent -> child relationships between fields.

I need to update some tests and I want to check and make sure nothing special needs to be done for rollups, but beyond that I believe the implementation is complete.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@Bargs Bargs added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 v7.2.0 labels Mar 21, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

thanks for adding this information toField. I was able to filter out multi fields in the Maps application and it worked as expected.

Should this PR also update the index-pattern saved objects for the sample data sets?

lgtm
code review, tested in chrome.

const parentFieldName = field.name.split('.').slice(0, -1).join('.');
const parentFieldCaps = kibanaFormattedCaps.find(caps => caps.name === parentFieldName);

if (!['object', 'nested'].includes(parentFieldCaps.type)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you check that parentFieldCaps is not undefined since find could return undefined if parentFieldName can not be found?

Copy link
Member

Choose a reason for hiding this comment

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

You should probably also check if the type is 'join' as well: https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added check for undefined.

I wasn't sure how join would be reported in field_caps so I tested it out. Looks like we don't need to worry about it. It's a bit different because the relationship is between documents, not fields, so the relationship is not represented with a dot in the field name. Here's a sample response with the extraneous meta fields removed:

{
  "fields" : {
    "my_join_field#question" : {
      "parent" : {
        "type" : "parent",
        "searchable" : true,
        "aggregatable" : true
      }
    },
    "_parent_join" : {
      "parent_join" : {
        "type" : "parent_join",
        "searchable" : false,
        "aggregatable" : false
      }
    },
    "my_join_field" : {
      "join" : {
        "type" : "join",
        "searchable" : true,
        "aggregatable" : true
      }
    },
    "text" : {
      "text" : {
        "type" : "text",
        "searchable" : true,
        "aggregatable" : false
      }
    },
    "text.keyword" : {
      "keyword" : {
        "type" : "keyword",
        "searchable" : true,
        "aggregatable" : true
      }
    },
  }
}

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Just after a cursory glance I think there are probably some other files that should be updated with these new properties (do a global search for readFromDocValues).

Also, did we want to include the actual field type as well? (e.g. whether it's text or keyword, etc.)


if (!['object', 'nested'].includes(parentFieldCaps.type)) {
field.parent = parentFieldName;
field.subType = 'multi';
Copy link
Member

Choose a reason for hiding this comment

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

Why not just have a isMulti boolean instead of adding another string property subType? What else could subType be?

Copy link
Member

Choose a reason for hiding this comment

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

Do we even need the multi designation? Can we just assume if parent is not undefined, it's multi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the future it could be nested, object, or join. I see this being used to describe any parent/child relationship between fields. I thought about just doing an isMulti flag but then we'd need to add isNested, isObject and isJoin in the future.

Instead of having a separate parent field and a flag we could also just have something like multiParent, nestedParent, objectParent, joinParent. We'd still have to add a new one for each new relationship type, but then they're not coupled together.

I dunno, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made all the updates I can without making a decision on this. Once we've agreed on a format I'll go through and update all the other places mentioned that need these properties.

@Bargs Bargs added the release_note:skip Skip the PR/issue when compiling release notes label Mar 27, 2019
@Bargs
Copy link
Contributor Author

Bargs commented Mar 28, 2019

Also, did we want to include the actual field type as well? (e.g. whether it's text or keyword, etc.)

I think this is an orthogonal concern. Having more detailed type info would be useful for all fields, not just subfields.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lukeelmers lukeelmers added Feature:Data Views Data Views code and UI - index patterns before 8.0 :AppArch labels Mar 28, 2019
Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@Bargs Bargs merged commit d8916e3 into elastic:master Apr 2, 2019
Bargs added a commit to Bargs/kibana that referenced this pull request Apr 2, 2019
Adds two fields to the IndexPattern Field:

* parent - the name of the field this field is a child of
* subType - The type of child this field is. Currently the only valid value is multi but we could expand this to include aliases, object children, and nested children.

The thinking behind implementing these two new properties instead of a simple isMultiField flag is that it should be generic enough to describe other sorts of parent -> child relationships between fields.
Bargs added a commit that referenced this pull request Apr 2, 2019
Adds two fields to the IndexPattern Field:

* parent - the name of the field this field is a child of
* subType - The type of child this field is. Currently the only valid value is multi but we could expand this to include aliases, object children, and nested children.

The thinking behind implementing these two new properties instead of a simple isMultiField flag is that it should be generic enough to describe other sorts of parent -> child relationships between fields.
@Bargs
Copy link
Contributor Author

Bargs commented Apr 3, 2019

@nreese @lukasolson embarrassingly, one thing I didn't think about until now is that old index patterns will not have this additional info until the fields are manually refreshed. I've attempted to hack my own auto field refresh in situations like this in the past and it turned out poorly with lots of edge cases.

As I understand it, our formal migration API cannot currently make http requests or access services because it happens early in the start up process. @elastic/kibana-platform am I right about this? Is there any way I could refresh the index pattern fields during a migration between minor versions (7.0 -> 7.1)?

@nreese
Copy link
Contributor

nreese commented Apr 3, 2019

Is there any way I could refresh the index pattern fields during a migration between minor versions (7.0 -> 7.1)

I am not sure users will appreciate having their index-pattern saved objects auto-refreshed when upgrading without some kind of explicit opt-in. Updating the index-pattern can introduce new fields and such if the index has changed. I think expecting the user to update their index-patterns on their own is ok.

@Bargs
Copy link
Contributor Author

Bargs commented Apr 3, 2019

I think expecting the user to update their index-patterns on their own is ok.

Ok, that's good input. One of my worries was that in maps you would not want the multi fields showing up until the user manually refreshes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Data Views Data Views code and UI - index patterns before 8.0 release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants