When you create a Script Field in kibana, it is nice to know if it is well processed and works with your index before doing a visualization. Indeed, it would be a pity to make a visualisation only to find out that it does not work. It is therefore possible, with Discover, to check if it works.
Let’s start by refreshing the index
First of all, don’t forget to refresh your index pattern to be sure that your Script Field will be taken into account. To do this, go to settings, then index pattern. At the top right, click on the double arrow to refresh the index pattern.
Check if your Script Field in kibana is working:
As said earlier, it is possible to check your Script Field. In Discover, on the left panel, you have all the fields available in your file. There are also the Scripted Fields you have created. To find out if your Script is working, look for it in the list of fields. Click the “Add” button on the line.
Discover will update itself.
In the Script Field I have, the script returns either 1 or -1 depending on certain criteria. Here, if our df_review_rating field is less than or equal to 3, then the script will return -1. However, if the df_review_rating field is greater than 3, the script will return 1.
On the right hand side of Discover, I see my file rows, and a review_calculated column (name of my Script Field) with 1 and -1.
So far, the script seems to be working.
Now we will see in more detail if it really works.
When we click on the arrow to the right of one of the lines in the file, we have all the details of the line displayed with each field name.
To see if our Script is being processed correctly, we look at the relevant field (here it will be df_review_rating). In our script, reviews less than or equal to 3 return -1. This is what we will check.
This is the case here.
To be sure, we will now check a line that returns 1. We do the same process. We click on the line, check the df_review_rating …
It is 5 and returns 1.
This corresponds to what we have configured in our script. It works and is therefore well processed.
Now you can check that your Script Field is taken into account before you can work with it!
If you are curious about what can be done with a Script Field, a webinar is available here: