Date Format Issue


(my3sons) #1

Hello,

I have created the below mapping, and my issue is with the "submissionTime"
field below. As you can see below, I have set the format to
"yyyy-MM-dd'T'HH:mm:ss", which matches both my incoming data and the format
described in the ES API docs. However, when I try and load this mapping, I
get the below error:

{"error":"ElasticSearchException[Illegal pattern component: T]; nested:
IllegalArgumentException[Illegal pattern component: T]; ","status":500}

Any ideas as to why it does not like the 'T' in the format?

curl -XPUT localhost:9200/reviews/test/_mapping -d '{

"terms" : {
"properties" : {
"comment" : {
"type" : "string",
"index" : "analyzed",
"includeInAll" : true
},
"rating" : {
"type" : "double",
"index" : "not_analyzed",
"includeInAll" : false
},
"title" : {
"type" : "string",
"index" : "not_analyzed",
"includeInAll" : false
},
"submissionTime" : {
"type" : "date",
"index" : "not_analyzed",
"includeInAll" : false,
"format" : "yyyy-MM-dd'T'HH:mm:ss"
},
"sku" : {
"type" : "integer",
"index" : "analyzed",
"includeInAll" : false
},
"id" : {
"type" : "integer",
"index" : "no",
"includeInAll" : false
},
"reviewer": {
"type": "object",
"properties": {
"name" : {"type" : "string", "index" : "not_analyzed",
"includeInAll" : false}
}
}

}
}
}
}'


(Igor Motov) #2

You are using single quotes for the entire JSON and for T. As a result, T
is sent without quotes. Try surrounding T with ''' like this:

"format" : "yyyy-MM-dd'''T'''HH:mm:ss"

On Monday, April 23, 2012 6:07:50 PM UTC-4, my3sons wrote:

Hello,

I have created the below mapping, and my issue is with the
"submissionTime" field below. As you can see below, I have set the format
to "yyyy-MM-dd'T'HH:mm:ss", which matches both my incoming data and the
format described in the ES API docs. However, when I try and load this
mapping, I get the below error:

{"error":"ElasticSearchException[Illegal pattern component: T]; nested:
IllegalArgumentException[Illegal pattern component: T]; ","status":500}

Any ideas as to why it does not like the 'T' in the format?

curl -XPUT localhost:9200/reviews/test/_mapping -d '{

"terms" : {
"properties" : {
"comment" : {
"type" : "string",
"index" : "analyzed",
"includeInAll" : true
},
"rating" : {
"type" : "double",
"index" : "not_analyzed",
"includeInAll" : false
},
"title" : {
"type" : "string",
"index" : "not_analyzed",
"includeInAll" : false
},
"submissionTime" : {
"type" : "date",
"index" : "not_analyzed",
"includeInAll" : false,
"format" : "yyyy-MM-dd'T'HH:mm:ss"
},
"sku" : {
"type" : "integer",
"index" : "analyzed",
"includeInAll" : false
},
"id" : {
"type" : "integer",
"index" : "no",
"includeInAll" : false
},
"reviewer": {
"type": "object",
"properties": {
"name" : {"type" : "string", "index" : "not_analyzed",
"includeInAll" : false}
}
}

}
}
}
}'


(my3sons) #3

dohhh :slight_smile: Thanks Igor, that did the trick!

On Monday, April 23, 2012 5:34:16 PM UTC-5, Igor Motov wrote:

You are using single quotes for the entire JSON and for T. As a result, T
is sent without quotes. Try surrounding T with ''' like this:

"format" : "yyyy-MM-dd'''T'''HH:mm:ss"

On Monday, April 23, 2012 6:07:50 PM UTC-4, my3sons wrote:

Hello,

I have created the below mapping, and my issue is with the
"submissionTime" field below. As you can see below, I have set the format
to "yyyy-MM-dd'T'HH:mm:ss", which matches both my incoming data and the
format described in the ES API docs. However, when I try and load this
mapping, I get the below error:

{"error":"ElasticSearchException[Illegal pattern component: T]; nested:
IllegalArgumentException[Illegal pattern component: T]; ","status":500}

Any ideas as to why it does not like the 'T' in the format?

curl -XPUT localhost:9200/reviews/test/_mapping -d '{

"terms" : {
"properties" : {
"comment" : {
"type" : "string",
"index" : "analyzed",
"includeInAll" : true
},
"rating" : {
"type" : "double",
"index" : "not_analyzed",
"includeInAll" : false
},
"title" : {
"type" : "string",
"index" : "not_analyzed",
"includeInAll" : false
},
"submissionTime" : {
"type" : "date",
"index" : "not_analyzed",
"includeInAll" : false,
"format" : "yyyy-MM-dd'T'HH:mm:ss"
},
"sku" : {
"type" : "integer",
"index" : "analyzed",
"includeInAll" : false
},
"id" : {
"type" : "integer",
"index" : "no",
"includeInAll" : false
},
"reviewer": {
"type": "object",
"properties": {
"name" : {"type" : "string", "index" : "not_analyzed",
"includeInAll" : false}
}
}

}
}
}
}'


(system) #4