Sort not working with complex query

I'm doing a complex query and sort returns the same results. Can anybody help me?

The query works fine returning the correct values but with or without sort option the results are the same.

Here's the search query

{
"limit": 2000,
"sort":[ "created": { "order": "desc" } ],
"filter": {
"bool": {
"must": [{
"geo_polygon": {
"location.geopoint.coordinates": {
"points": [
[-90, -90],
[-90, 90],
[90, 90],
[90, -90]
]
}
}
}, {
"term": {
"status": "active"
}
}, {
"bool": {
"should": [{
"term": {
"basic.pSubType": "kljhfgdfgvf"
}
}, {
"term": {
"basic.pSubType": "asdqwesdf"
}
}]
}
}, {
"range": {
"property.bthrms": {
"gte": 0,
"lte": 20
}
}
}, {
"bool": {
"should": [{
"term": {
"property.energy": 2
}
}, {
"term": {
"property.energy": 3
}
}]
}
}, {
"bool": {
"should": [{
"term": {
"building.bFacils": "asdqwe"
}
}, {
"term": {
"building.bFacils": "asdasd"
}
}]
}
}, {
"bool": {
"should": [{
"bool": {
"must": [{
"term": {
"basic.pSubType": "loort"
}
}, {
"range": {
"building.height": {
"gte": 6
}
}
}, {
"range": {
"property.flrNr": {
"lte": 6
}
}
}]
}
}, {
"bool": {
"must": [{
"term": {
"basic.pSubType": "eirthertr"
}
}, {
"range": {
"building.height": {
"gte": 2,
"lte": 20
}
}
}, {
"range": {
"property.flrNr": {
"gte": -5
}
}
}]
}
}]
}
}, {
"term": {
"basic.operation": "buy"
}
}, {
"range": {
"basic.price": {
"gte": 466
}
}
}, {
"range": {
"basic.priceRatio": {
"gte": 50,
"lte": 500000
}
}
}, {
"range": {
"property.surface": {
"gte": 30,
"lte": 56000
}
}
}, {
"range": {
"property.bdrms": {
"lte": 50
}
}
}]
}
}
}

What is the datatype of the created field?

It's date type. But even if I try to sort by _id doesn't work with this query.

If I do a simple match_all query, sort goes well.

Check again your sort parameter, the syntax is wrong, it must be like this :

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

I found it was my error running the search from command line with curl.

My query was ok but "limit" should be "size".

Thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.