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

Allow scripted_field values to dynamically recalculate with refresh interval #12650

Closed
jclosure opened this issue Jul 3, 2017 · 3 comments
Closed
Labels
Feature:Discover Discover Application release_note:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.

Comments

@jclosure
Copy link

jclosure commented Jul 3, 2017

Describe the feature:

It would be really useful to be able to opt scripted_fields out of request caching. Here is an example of a scripted_field that produces different output each time the Painless script in it runs.

Example

long seconds = (new Date().getTime() - doc['@timestamp'].value) / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long days = hours / 24;

long ss = seconds % 60;
long mm = minutes % 60;
long hh = hours % 24;

def[] args = new def[] {hh, mm, ss};
if (days == 0) {
  return String.format ("%02d:%02d:%02d", args);
} else {
  return "days: " + days + ", " + String.format ("%02d:%02d:%02d", args);
}

image

The Duration till Now field's value gets calculated on initial page load. After that it's cached, it doesn't update each time the automatic refresh happens. The caching behavior doesn't allow for dynamically recalculating query values. It would very powerful and a nice user experience to be able to have Painless scripted_fields rerun each time the refresh interval fires. If possible it would be nice to be able to configure each scripted_field to opt in/out of caching on an individual basis.

@Bargs
Copy link
Contributor

Bargs commented Jul 3, 2017

The scripted fields are getting recalculated on each request to Elasticsearch, we're just not showing you the updates. This is more of a general issue with the way the doc table is architected. We solved the problem for non-scripted fields by adding the document's version to the table's ng-repeat track by, but the version obviously doesn't increment when scripted fields change.

We're planning on refactoring the doc table in the future which should make this a non-issue for any doc changes, regardless of field type.

@Bargs Bargs added the Feature:Discover Discover Application label Jul 3, 2017
@jclosure
Copy link
Author

jclosure commented Dec 2, 2017

Perhaps a per field version tracker could be used to invalidate changed values in individual cells in DiscoveryTable.

@timroes timroes added Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure :Discovery labels Sep 16, 2018
@jclosure jclosure changed the title Allow scripted_field value to dynamically recalculate with refresh interval Allow scripted_field values to dynamically recalculate with refresh interval Mar 19, 2019
@timroes timroes added Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Aug 31, 2021
@lukasolson
Copy link
Member

This appears to have been resolved with the doc table rewrite.

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:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
Projects
None yet
Development

No branches or pull requests

5 participants