Hi,
I couldn't find the details in the documentation, so I hope somebody here will be able to help; I'm curious when the scripted field defined in Kibana is executed? Is it executed on each query, or does Elasticsearch somehow cache the values?
My queries often result with more than 50,000,000 documents, and I have 5 scripted fields defined in the index pattern. The scripted fields consist of bunch of if's on string fields. I'm bit worried that this causes dashboards to be slow at responses.
Is it recommended, in this scenario, to pre-compute fields before inserting data to elastic search, instead of building scripted fields? I do understand that the advantage of scripted field is the ability to update the value for document at any time, although in my case performance is the higher priority.
Scripted fields executes when you trigger a search from Kibana, hence the word "on the fly"
Scripted fields compute data on the fly from the data in your Elasticsearch indices
The scripted field values are computed at query time, so they aren’t indexed and cannot be searched using the Kibana default query language.
For your second query, Scripted field do impact performance as it is expensive.
You should observe the performance differences between with / without scripted field and determine if the performance is up to your prioritized expectation.
Computing data on the fly with scripted fields can be very resource intensive and can have a direct impact on Kibana performance.
Thanks a lot, I think you confirmed what I suspected. Do you know if there's a way to persist the result of scripted field so it's only executed when the document is added or cached on the first query, and only re-run the script on demand for existing documents if needed?
scripted fields, Kibana adds a layer on top of that and remembers to attach them to each request Kibana is making on your behalf. You can't persist them directly as part the Elasticsearch index.
This won't save the script itself, but the computed values in the Elasticsearch index. This also means you have to re-index your data if you ever change your script, but it will be much more efficient while querying data.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.