European and American date formats


(Lenak) #1

Hello, Shay

How I can to define date format in mapping that allow me to search on a date field by range in European and American formats like
[2010-08-11 TO 2010-08-30] or [08/11/2010 TO 08/30/2010]

I try to define date format like

"format":"yyyy-MM-dd||yyyy/MM/dd||MM/dd/yyyy"

But I got error when try to write document
{"error":"ReplicationShardOperationFailedException[[111111][4] ]; nested: MapperParsingException[Failed to parse [case.d
ate_created]]; nested: IllegalArgumentException[Invalid format: "2010/10/10" is too short]; "}

$ curl -XPUT 'http://localhost:9200/111111/OBJ/2' -d '
{
"case" : {
"title": "privet1",
"date_created" : "2010/10/10"
}
}'
It is working after that I delete American format definition from formats and format
"format":"yyyy-MM-dd||yyyy/MM/dd"


(Shay Banon) #2

This should work, can you open an issue with a simpel curl recreation, I
will look at this (in the middle of another feature).

-shay.banon

On Mon, Aug 23, 2010 at 10:48 AM, Lenak lenakovganov@gmail.com wrote:

Hello, Shay

How I can to define date format in mapping that allow me to search on a
date
field by range in European and American formats like
[2010-08-11 TO 2010-08-30] or [08/11/2010 TO 08/30/2010]

I try to define date format like

"format":"yyyy-MM-dd||yyyy/MM/dd||MM/dd/yyyy"

But I got error when try to write document
{"error":"ReplicationShardOperationFailedException[[111111][4] ]; nested:
MapperParsingException[Failed to parse [case.d
ate_created]]; nested: IllegalArgumentException[Invalid format:
"2010/10/10" is too short]; "}

$ curl -XPUT 'http://localhost:9200/111111/OBJ/2' -d '
{
"case" : {
"title": "privet1",
"date_created" : "2010/10/10"
}
}'
It is working after that I delete American format definition from formats
and format
"format":"yyyy-MM-dd||yyyy/MM/dd"

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/European-and-American-date-formats-tp1285438p1285438.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(system) #3