Using a long value as a date

Currently, the only format supported for the date mapping are those
defined by JodaTime. Would it be possible have documents where the
date fields are defined by longs (milliseconds)? In other words,
storing the value without the need for a parser.

I knew it would return an error, but I still attempted to do so out of
curiosity.

curl -XPUT 'http://127.0.0.1:9200/someindex/sometype/_mapping' -d '
{
"sometype" : {
"properties" : {
"mtime" : {
"type" : "date"
}
}
}
}
'

{"error":"MergeMappingException[Merge failed with failures {[mapper
[mtime] of different type, current_type [long], merged_type
[date]]}]","status":400}

I have no control over the JSON being indexed. The goal is to index
any JSON document passed in with a predefined external mapping.

Actually, it appears that the date histogram facet works well with
unmapped long values. I assumed it would not work since the
documentation states "A specific histogram facet that can work with
date field types", but the field does not have to be date.

On Mar 6, 2:02 pm, Ivan Brusic ivan_bru...@yahoo.com wrote:

Currently, the only format supported for the date mapping are those
defined by JodaTime. Would it be possible have documents where the
date fields are defined by longs (milliseconds)? In other words,
storing the value without the need for a parser.

I knew it would return an error, but I still attempted to do so out of
curiosity.

curl -XPUT 'http://127.0.0.1:9200/someindex/sometype/_mapping' -d '
{
"sometype" : {
"properties" : {
"mtime" : {
"type" : "date"
}
}
}}

'

{"error":"MergeMappingException[Merge failed with failures {[mapper
[mtime] of different type, current_type [long], merged_type
[date]]}]","status":400}

I have no control over the JSON being indexed. The goal is to index
any JSON document passed in with a predefined external mapping.

Right, since internally it just works with long values of milliseconds since the epoch, you can actually run it on long type fields as well. Note, it is expected that those are UTC.
On Sunday, March 6, 2011 at 11:27 PM, Ivan Brusic wrote:

Actually, it appears that the date histogram facet works well with
unmapped long values. I assumed it would not work since the
documentation states "A specific histogram facet that can work with
date field types", but the field does not have to be date.

On Mar 6, 2:02 pm, Ivan Brusic ivan_bru...@yahoo.com wrote:

Currently, the only format supported for the date mapping are those
defined by JodaTime. Would it be possible have documents where the
date fields are defined by longs (milliseconds)? In other words,
storing the value without the need for a parser.

I knew it would return an error, but I still attempted to do so out of
curiosity.

curl -XPUT 'http://127.0.0.1:9200/someindex/sometype/_mapping' -d '
{
"sometype" : {
"properties" : {
"mtime" : {
"type" : "date"
}
}
}}

'

{"error":"MergeMappingException[Merge failed with failures {[mapper
[mtime] of different type, current_type [long], merged_type
[date]]}]","status":400}

I have no control over the JSON being indexed. The goal is to index
any JSON document passed in with a predefined external mapping.