Doc Script Fields - Date Fields outside of index



We have a date field called "time_posted" which is date. Here's our mapping:

                "time_posted": {
                    "type": "date",
                    "index": "no",
                    "format": "dateOptionalTime",
                    "include_in_all": false

As you can see it is outside of the index. I'm trying to build a script for a field which does some date arithmetic (pretty simple actually, just number of days between the date and now). But having a heck of a time actually retrieving the field as a "doc" field. I've reduced my script down to the following:

return doc['time_posted'].empty

It returns "true" for every document. However, when I use this as the script, it returns proper dates for each record (but only in string format):

  return _source.time_posted 

Any idea what is going on? Something to do with my index and/or mapping?


Anyone? It seems no matter what I do with that mapping, it wont seem to allow me to use the doc property to retrieve data.

(system) #3