Created
January 8, 2013 10:19
-
-
Save anonymous/4482696 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPUT http://localhost:9200/business_index/business_time_span_slot/_mapping -d '{"business_time_span_slot": {"properties": {"hour_from": {"index": "not_analyzed", "type": "date", "store": "no", "format": "HH:mm:ss"}, "hour_till": {"index": "not_analyzed", "type": "date", "store": "no", "format": "HH:mm:ss"}}}}' | |
curl -XPUT http://localhost:9200/business_index/business_time_span_slot/1 -d '{"hour_from": "11:10:23", "hour_till": "12:10:23"}' | |
curl -XPUT http://localhost:9200/business_index/business_time_span_slot/2 -d '{"hour_from": "12:10:00", "hour_till": "12:15:00"}' | |
curl -XPOST http://localhost:9200/business_index/business_time_span_slot/_search/ -d '{ | |
"filter": { | |
"and": [ | |
{ | |
"range": { | |
"hour_from": { | |
"lte": "10:59:00" | |
} | |
} | |
}, | |
{ | |
"range": { | |
"hour_till": { | |
"gte": "10:58:00" | |
} | |
} | |
}] | |
}, | |
"query": {"match_all": {}} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK - I think this should be considered a bug. The reason for this is the inconsistent handling of times when no date has been specified. Have a look at the actual values stored for
hour_from
andhour_till
:For instance
12:10:00
is stored as43800000
, which isThu Jan 1 12:10:00 1970
.However, your query is translated to:
So the
lte
value is32535169140999
, which is:Wed Dec 31 10:59:00 3000
This is obviously inconsistent. I'm not sure what is required to fix this: whether we need a
time
field type, or whether we can just consider missing year/month/day to always be Jan 1 1970.