Hi, I'm having an issue querying for dates, and it's probably me using
the query dsl wrong, but I can't figure out what the problem is.
This query works:
{
"query":{
"range":{
"created_at":{
"from":"2010-08-26T20:41:52Z",
"to":"2010-08-26T20:41:52Z"
}
}
}
}
but this query doesn't:
{
"query":{
"field":{
"created_at":"2010-08-26T20:41:52Z"
}
}
}
It throws this exception: http://gist.github.com/552231
I'm using 0.9.0 for this test.
Is there something wrong here?
Oh also here's the mapping for that field:
"created_at" : {
"omit_term_freq_and_positions" : true,
"index_name" : "created_at",
"index" : "not_analyzed",
"omit_norms" : true,
"store" : "no",
"boost" : 1.0,
"format" : "dateOptionalTime",
"precision_step" : 4,
"term_vector" : "no",
"type" : "date"
},
On Aug 26, 1:57 pm, Grant Rodgers gra...@gmail.com wrote:
Hi, I'm having an issue querying for dates, and it's probably me using
the query dsl wrong, but I can't figure out what the problem is.
This query works:
{
"query":{
"range":{
"created_at":{
"from":"2010-08-26T20:41:52Z",
"to":"2010-08-26T20:41:52Z"
}
}
}
}
but this query doesn't:
{
"query":{
"field":{
"created_at":"2010-08-26T20:41:52Z"
}
}
}
It throws this exception:gist:552231 · GitHub
I'm using 0.9.0 for this test.
Is there something wrong here?
but this query doesn't:
{
"query":{
"field":{
"created_at":"2010-08-26T20:41:52Z"
}
}
}
A 'field' query is for query strings. Use a term query instead:
{
"query":{
"field":{
"term":"2010-08-26T20:41:52Z"
}
}
}
clint
Ah, it makes sense now that I know field queries are query strings,
because colons are reserved in query strings. Escaping the colons
fixes the query:
{
"query":{
"field":{
"created_at":"2010-08-26T20\:41\:52Z"
}
}
}
(double backslashes so the json parser doesn't throw an error)
Thanks!
On Aug 26, 2:38 pm, Clinton Gormley clin...@iannounce.co.uk wrote:
but this query doesn't:
{
"query":{
"field":{
"created_at":"2010-08-26T20:41:52Z"
}
}
}
A 'field' query is for query strings. Use a term query instead:
{
"query":{
"field":{
"term":"2010-08-26T20:41:52Z"
}
}
}
clint