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

[Discover] Show correct data for top level object columns #91954

Merged
merged 8 commits into from
Feb 22, 2021

Conversation

wylieconlon
Copy link
Contributor

@wylieconlon wylieconlon commented Feb 18, 2021

This can be tested with the kibana_sample_data_ecommerce data set. I recommend adding a KQL search for products.product_name: Boots to test the highlighting feature.

The easiest way to test is to modify the URL by looking for columns:!() or columns:!(_source) and replace this with columns:!(products). Then save the search. This is because on master, it's not possible to select the products column from the list of fields: this is working as expected, but users may have previously saved searches on top level objects.

Before this, we are trying to basically improve on the behavior from 7.11:

Screen Shot 2021-02-18 at 6 07 05 PM

Here are the scenarios that I have tested:

// closest to 7.11
discover:searchFieldsFromSource: true
doc_table:legacy: true

Screen Shot 2021-02-18 at 6 08 55 PM

// potential default for 7.12
discover:searchFieldsFromSource: true
doc_table:legacy: true

Screen Shot 2021-02-18 at 6 11 02 PM

// with data grid but legacy fetching
discover:searchFieldsFromSource: false
doc_table:legacy: false

Screen Shot 2021-02-18 at 6 11 20 PM

// with data grid and new data
discover:searchFieldsFromSource: false
doc_table:legacy: false

Screen Shot 2021-02-18 at 6 11 51 PM

cc @mattkime because I've implemented some logic custom to Discover that is maybe better suited to the index pattern API

Closes #91953

Checklist

@wylieconlon wylieconlon added Feature:Discover Discover Application v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.12.0 v7.13.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Feb 18, 2021
@wylieconlon wylieconlon marked this pull request as ready for review February 18, 2021 23:14
@wylieconlon wylieconlon requested a review from a team February 18, 2021 23:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@wylieconlon wylieconlon requested a review from timroes February 18, 2021 23:15
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

  • Breaks properties of enabled: false object fields (shown as empty)
  • Breaks properties of enabled: false object fields, enabled: false object root fields and nested fields for data grid (all shown as empty - these work fine in the legacy table)

const highlightPairs: Array<[string, string]> = [];
const sourcePairs: Array<[string, string]> = [];
Object.entries(innerColumns).forEach(([key, values]) => {
const subField = indexPattern.getFieldByName(key)!;
Copy link
Contributor

Choose a reason for hiding this comment

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

This subField can be undefined if the object is enabled: false, crashing discover.

@wylieconlon
Copy link
Contributor Author

wylieconlon commented Feb 19, 2021

@flash1293 fixed and added unit tests. Here are the two scenarios when dealing with unmapped fields:

Screen Shot 2021-02-19 at 12 58 49 PM

Screen Shot 2021-02-19 at 1 08 51 PM

@kertal
Copy link
Member

kertal commented Feb 22, 2021

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tried around and wasn't able to break it, LGTM

We can think about formatting nested objects the same way (with highlighted keys), but it's probably not that easy to achieve. Definitely not necessary:
Screenshot 2021-02-22 at 10 47 05

const subField = indexPattern.getFieldByName(key);
const formatter = subField
? indexPattern.getFormatterForField(subField)
: { convert: (v: string, ...rest: unknown[]) => v.toString() };
Copy link
Member

Choose a reason for hiding this comment

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

Even if I can't think of a situation where null comes around, String(v) would be prepared for this impossible event.

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Great work dear @wylieconlon , thanks a lot for fixing highlighting for the data grid as a side effect. Tested locally in Chrome, Firefox, Safari, MacOs ... works as expected

@wylieconlon
Copy link
Contributor Author

Thanks @kertal updated from your suggestion. @flash1293 I opened an issue for that: #92223

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 397.3KB 400.2KB +3.0KB

History

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

@wylieconlon wylieconlon merged commit 4614202 into elastic:master Feb 22, 2021
@wylieconlon wylieconlon deleted the discover-top-level-fields branch February 22, 2021 19:24
wylieconlon pushed a commit to wylieconlon/kibana that referenced this pull request Feb 22, 2021
)

* [Discover] Show correct data for top level object columns

* Fix bug with missing fields

* Fix bug in data grid

* Fix remaining bug in datagrid

* Change use of API to work with any type

Co-authored-by: Kibana Machine <[email protected]>
wylieconlon pushed a commit that referenced this pull request Feb 22, 2021
…92268)

* [Discover] Show correct data for top level object columns

* Fix bug with missing fields

* Fix bug in data grid

* Fix remaining bug in datagrid

* Change use of API to work with any type

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
wylieconlon pushed a commit that referenced this pull request Feb 22, 2021
…92269)

* [Discover] Show correct data for top level object columns

* Fix bug with missing fields

* Fix bug in data grid

* Fix remaining bug in datagrid

* Change use of API to work with any type

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discover] Missing data on top-level object fields when switching from _source-based to fields-based data
5 participants