I searched a lot but confused .
how can i check if a string is date or not in ruby filter ?
I searched a lot but confused .
how can i check if a string is date or not in ruby filter ?
Your question would be easier to answer with more context. Why do you need to check in a ruby filter if a string contains a date?
because i am splitting a string like this
f1=2015-08-09@f2=45@f3=alice
and then converting thier values accordingly do their data types .
like
"f1":2015-08-09, //date
"f2":45, //integer
"f3":"alice" //text
And you can't use the date filter because you don't know all possible names of the date fields?
I'd try to parse the date and catch any parse exception so that I can fall back to e.g. a string. Are you going to perform date arithmetic on the parsed date, or why do you need a Date object?
I need date object because I would perform range query on date .
And yes i don't know the date field name because i am extracting it from a string which can contain anything .
can you please suggest how to catch exception in ruby ,so that if its not a date it will give me the string as it is ?
I need date object because I would perform range query on date .
What, inside the Ruby filter?
can you please suggest how to catch exception in ruby ,so that if its not a date it will give me the string as it is ?
I'm not fluent in Ruby myself but I'm sure there are many Ruby tutorials and other online documents that explain the syntax and semantics of Ruby's exception handling.
Its ok magnus ! Thanks anyway
© 2020. All Rights Reserved - Elasticsearch
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.