Searching for a scripted Date in custom format


I have a field named date which has current date in long format and I have added a scripted field called log date which converts long into human readable format.Is there any way to search for a date in Human readable format itself?Because when I search in that format it shows no result but when searched in long format it works.

(Chris Davies) #2

Not in the way you want, no. From the docs:

Scripted field values are computed at query time so they aren’t indexed and cannot be searched.

So, if you really want to search that field, you need to store it in elasticsearch in the format that you want to search.


Thanks for your reply.In that case is there any way to store the scripted data in elasticsearch?

(Chris Davies) #4

How is your data getting into Elasticsearch in the first place? In my opinion, that's where you should do the transformation, and store it in an appropriately typed field. If you're using one of Elastic's tools (such as logstash) to get the data into Elasticsearch, the tool should have some support for transforming data during ingest. But if it's coming from elsewhere, you'll probably have to figure out how to hack around whatever tool you're using.

(system) #5

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