Use date field as time-only field and query question


(Thorsten-2) #1

Dear ES,
I'm trying to work with a time-only field, to represent business hours.

I've set the mapping to 'date' with format 'hour_minute_second', so far, so
good:

"open" : {
        "type" : "date",
        "format" : "hour_minute_second"
      },
"close" : {
        "type" : "date",
        "format" : "hour_minute_second"
      },

First problem: If a company is opened until midnight, I'd have to save
'24:00:00' in the field, but that is not possible (not regarded as valid
time).

Second question, since I'd like to query companies that are opened at the
moment, how can I build a query that selects all entires where NOW() is
between field "open" and field "close"?

Thanks for your help

Thorsten


(system) #2