Current Time

Hi,

Is there someway to get current time at script fields? Usually for getting in range I can use now, but for scripted query it returns as string. I've searched some topic and it said, it must be send by params. Is there any guide for doing this?

Thank you

hi,
i understood that under script fields you mean bash scripts?
if that, so you can use in range query values like:

"'date '+%Y-%m-%dT%H:%M:%S%Z''"

, that return current time.
here example with range from 4 hour from now to now

curl localhost:9200/sslogger_index/events/_search -d '{"query": {"range": {"event_date": {"gte":"'date '+%Y-%m-%dT%H:%M:%S%Z' -d '4 hour ago''", "lt":"'date '+%Y-%m-%dT%H:%M:%S%Z''"}}}}'

Hi,

No, I mean the painless one. as we used in scripted field for elastic search. I use kibana console for query and search the elastic search.

Thank you

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.