Sort by created_at not working


(Martin Stabenfeldt) #1

Hi,

I'm trying to fetch all Ads that are active and sort them by created_at,
but the order is the same with and without the sort params. Same order when
I flip order from asc to desc.

What am I doing wrong? :expressionless:

GET _search
{
"query": {
"match_all": {},
"constant_score" : {

    "filter" : {
        "term" : { "state" : "active"}
    }

}

},
"sort": [
{
"created_at": {
"order": "asc"
}
}
]
}

Cheers,
Martin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1709156a-55fd-47bb-8a47-a8ce9fc3d5a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Martin Stabenfeldt) #2

Got it working! :slight_smile:

GET _search
{
"query": {
"match_all": {}
},
"filter" : {
"term" : { "state" : "active"}
},

"sort": [
{
"created_at": {
"order": "desc"
}
}
]

}

On Friday, April 11, 2014 10:50:45 AM UTC+2, Martin Stabenfeldt wrote:

Hi,

I'm trying to fetch all Ads that are active and sort them by created_at,
but the order is the same with and without the sort params. Same order when
I flip order from asc to desc.

What am I doing wrong? :expressionless:

GET _search
{
"query": {
"match_all": {},
"constant_score" : {

    "filter" : {
        "term" : { "state" : "active"}
    }

}

},
"sort": [
{
"created_at": {
"order": "asc"
}
}
]
}

Cheers,
Martin

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e0ae678b-bee6-4406-9c2c-fea27cd7999a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3