Date order working for "desc" and not for "asc"


(R Donovan) #1

For a custom formatted date mapping.. I have a strange problem where the i
get the expected result for "desc" but get the insertion result for "asc"??

For the hand crafted mapping .. with a custom date format

PUT test2/

{
"test2": {
"properties": {
"event": {
"time": {
"type": "date",
"store": "yes",
"format": "yyyy/MM/dd HH:mm:ss.SSS",
"index": "analyzed"
},
"eventKey": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"channelid": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"type": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"line": {
"type": "string",
"store": "yes",
"index": "analyzed"
}
}
}
}
}

for the dates entered, that differ by seconds

"time": "2012/12/01 12:01:30.001",
"time": "2012/12/01 12:01:32.001",
"time": "2012/12/01 12:01:31.001",

the expected sorted order is returned for { "event.time" : {"order" :
"desc"} however for {"order" : "asc"} it is returning the insertion
order

I also not the sort values for "desc" are
"sort": ["30.001"]
"sort": ["31.001"]
"sort": ["32.001"]

while for "asc"

"sort": [ "01"]
"sort": [ "01"]
"sort": [ "01"]

Any solution or hints would be greatly appreciated

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Alexander Reelsen) #2

Hey,

your mapping seems wrong.. if you create a object hierarchy, you need to
use the properties field as well, like this

curl -X PUT localhost:9200/test -d '
{
"test2": {
"properties": {
"event": {
"properties": {
"time": {
"type": "date",
"store": "yes",
"format": "yyyy/MM/dd HH:mm:ss.SSS",
"index": "analyzed"
}
}
}
}
}
}
'

that should make it work.

--Alex

On Mon, Nov 4, 2013 at 10:50 PM, R Donovan rdonovan2004@gmail.com wrote:

For a custom formatted date mapping.. I have a strange problem where the i
get the expected result for "desc" but get the insertion result for "asc"??

For the hand crafted mapping .. with a custom date format

PUT test2/

{
"test2": {
"properties": {
"event": {
"time": {
"type": "date",
"store": "yes",
"format": "yyyy/MM/dd HH:mm:ss.SSS",
"index": "analyzed"
},
"eventKey": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"channelid": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"type": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"line": {
"type": "string",
"store": "yes",
"index": "analyzed"
}
}
}
}
}

for the dates entered, that differ by seconds

"time": "2012/12/01 12:01:30.001",
"time": "2012/12/01 12:01:32.001",
"time": "2012/12/01 12:01:31.001",

the expected sorted order is returned for { "event.time" : {"order" :
"desc"} however for {"order" : "asc"} it is returning the insertion
order

I also not the sort values for "desc" are
"sort": ["30.001"]
"sort": ["31.001"]
"sort": ["32.001"]

while for "asc"

"sort": [ "01"]
"sort": [ "01"]
"sort": [ "01"]

Any solution or hints would be greatly appreciated

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3