Return only the YYYY-MM-DDD from date field - can I do that with a script?


(carl) #1

I have some date type data coming back from a query, like the example below
field "signupDate". Can I query and have the date only return the calendar
date and drop the hours, minutes, etc. Would I do that with a script
field? This signup date is entered as system time and i can't change that,
but when I query it I just wan to see the signup date as a normal date.

    "hits": [
        {
            "_index": "index1",
            "_type": "type1",
            "_id": "6ctRoz-0RI24Lu2FRZXwOQ",
            "_score": 1,
            "fields": {
                "signupDate": [
                    "2014-01-03T04:22:43.502586"
                ],
                "accountNumber": [
                    358666
                ]
            }
        },

...

Here's the query I'm using:

{ "query": {"filtered": {
"query": {"match_all": {}},
"filter": {"range": {
"signupDate": {
"from": "2014-01-01",
"to": "2014-01-15"
}
}
}
}
},
"fields": [
"accountNumber","signupDate"]
}

The signupDate field is defined as:

                "signupDate": {
                    "type": "date",
                    "format": "dateOptionalTime"
                },

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ab61156a-c405-48f0-9b1b-95d47155960f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2