-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
Pinging @elastic/kibana-app |
💔 Build Failed |
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.
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)) { |
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.
Should you check that parentFieldCaps
is not undefined since find
could return undefined if parentFieldName can not be found?
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.
You should probably also check if the type is 'join'
as well: https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
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.
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
}
},
}
}
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.
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'; |
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.
Why not just have a isMulti
boolean instead of adding another string property subType
? What else could subType
be?
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.
Do we even need the multi
designation? Can we just assume if parent
is not undefined, it's multi?
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.
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?
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'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.
I think this is an orthogonal concern. Having more detailed type info would be useful for all fields, not just subfields. |
💚 Build Succeeded |
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.
LGTM
💚 Build Succeeded |
💚 Build Succeeded |
💚 Build Succeeded |
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.
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.
@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)? |
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. |
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. |
Summary
Fixes #31921
Related to #7419
Adds two fields to the IndexPattern Field:
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
strikethroughsto 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- [ ] This was checked for keyboard-only and screenreader accessibilityFor 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