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

Elasticsearch: Guess field type from first non-empty value #32290

Merged
merged 1 commit into from Mar 26, 2021

Conversation

Elfo404
Copy link
Member

@Elfo404 Elfo404 commented Mar 24, 2021

What this PR does / why we need it:
When parsing an elasticsearch response, every field is treated as a string, which makes it impossible to, for example, work with thresholds in panels. With this change the field type is guessed from the first non-empty value in the returned document set.

Which issue(s) this PR fixes:

Fixes #29431

Special notes for your reviewer:

The solution is not perfect as in order to correctly know the type we should get the mappings for the current index.
This, for example, will detect time fields as string. a future improvement could be requesting the mapping when receiving the response in order to correctly assign the type, but given we want to migrate the response parser to the backend i'd leave this to a future implementaiton.

@Elfo404 Elfo404 added this to the 8.0.0 milestone Mar 24, 2021
@Elfo404 Elfo404 requested a review from a team as a code owner March 24, 2021 13:36
@Elfo404 Elfo404 requested review from ifrost and removed request for a team March 24, 2021 13:36
@Elfo404 Elfo404 merged commit 85a6544 into master Mar 26, 2021
@Elfo404 Elfo404 deleted the gio/fix/es-field-types branch March 26, 2021 16:08
ryantxu pushed a commit to dejapong/grafana that referenced this pull request Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elasticsearch: Raw data mode adds all fields as string
3 participants