Hi....Thank you for your response
when i use below code for scripted field
def m = /(.*)/.matcher(doc['ConfigRules.ConfigRuleArn.keyword'].value);
if ( m.matches() ) {
return m.group(1)
} else {
return "no match"
}
it throws this "Courier Fetch: 3 of 5 shards failed." and
scripted field is created but it holds no value it says "This field is present in your elasticsearch mapping but not in any documents in the search results. You may still be able to visualize or search on it." and i have not get results in discovery phase too
the field"ConfigRules.ConfigRuleArn.keyword" is nested
but when i make use of root fields(top level fields) like message its working fine
I am lost here :). Can you give us some more details on what you are trying to do here?
Also can you add null check before matching and see what happens?
Also, I would try to start out with the most simple scripted field first to make sure you're getting the data you expect before going on to a more complicated script since they can be challenging to debug.
So for example, if I just want to make sure I can use a field in a script I might start out with something like this;
doc['geo.srcdest'].value
And then go to Discover and add that field to the doc table view. If there are any docs that don't have this field it will fail. Then you know you need that check first.
The other thing to consider is if you can accomplish your needs without using regular expressions (just because that's something else you have to enable in your Elasticsearch config).
Like it says here; https://www.elastic.co/blog/using-painless-kibana-scripted-fields
"Note: Whenever possible, avoid using regex expressions to extract substrings, as indexOf() operations are less resource-intensive and less error-prone. "
if (!doc['ConfigRules.ConfigRuleArn.keyword'].empty) {
return doc['ConfigRules.ConfigRuleArn.keyword'].value ;
}
return null;
These test are failed
NOTE:
using the doc keyword, will cause the terms for that field to be loaded to memory (cached), which will result in faster execution, but more memory consumption. Also, the doc[...] notation only allows for simple valued fields (can’t return a json object from it) and make sense only on non-analyzed or single term based fields.
when i checked in kibana field "ConfigRules.ConfigRuleArn.keyword" is under "analyzed"
so am i doing mistake here....?
Yes, I'm pretty sure that you can only use fields that are both searchable and aggregatable and not analyzed in scripted fields. And keywords usually have those correct attributes.
If you really need that field and/or some regular expression match of it I think you'll need to go back and look at how the data is being loaded, if there's a mapping for the index, and/or if the default mapping has been changed.
And if you do have to change mapping and possibly reload data, you might also be able to parse it on the ingest side so that you don't have to use a scripted field in Kibana.
What are you using to load the data? And what version of Elasticsearch and Kibana are you on?
Thank you for making clear about scripted fields
i am using
logstash 5.3.0
kibana 5.3.0
elasticsearch 5.3.0
and i make use of logstash grok to create those fields and its worked
Thank you
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.