How to sort search serults #321
-
| Hello. I am wondering if there is a way to sort the search result. Thank you. | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            StijnCaerts
          
      
      
        Dec 11, 2024 
      
    
    Replies: 2 comments
-
| Hi @piust, I had a look at your example and there are a few things that might need to be fixed: 
 I modified your example into a working query with sorting: {
  "filter": {
    "op": "and",
    "args": [
      {
        "op": "and",
        "args": [
          {
            "op": "=",
            "args": [
              {
                "property": "properties.constellation"
              },
              "sentinel-2"
            ]
          }
        ]
      },
      {
        "op": ">=",
        "args": [
          {
            "property": "properties.updated"
          },
          {
            "timestamp": "2024-11-10T00:00:00.000Z"
          }
        ]
      }
    ]
  },
  "collections": [
    "sentinel-2-l2a"
  ],
  "fields": {
    "include": [
      "properties",
      "geometry",
      "type",
      "id",
      "bbox",
      "stac_version",
      "assets",
      "collection"
    ]
  },
  "limit": 100,
  "sortby": [
    {
      "field": "properties.updated",
      "direction": "desc"
    }
  ]
}I hope this helps! | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        piust
-
| Thank you @StijnCaerts. You are right. I Fixed it and now it works perfectly. | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Hi @piust, I had a look at your example and there are a few things that might need to be fixed:
properties.publishedis not a default field in STAC. You can take a look at the created/updated fieldsortbyfield should be an array of sort keysI modified your example into a working query with sorting:
{ "filter": { "op": "and", "args": [ { "op": "and", "args": [ { "op": "=", "args": [ { "property": "properties.constellation" }, "sentinel-2" ] } ] }, { "op": ">=", "args": [ { "property"…