Sorting
Request
Method: POST
Endpoint: /v1.4/search
Fields
| Field | Type | Required | Default | Description | 
|---|---|---|---|---|
| customer_id | String | Yes | Random unique customer id generate by PA tracker | |
| website_id | String | Yes | Client unique website id provided by PA | |
| q | String | Yes | Input search query string | |
| client | String | Yes | Unique client shortcode provided by PA | |
| start | Integer | Yes | Defines the offset from the first result you want to fetch | |
| size | Integer | No | 20 | The max number of results you want returned with your query | 
| sort_fields | Object Array | No | Relevance Score | Sorting search results based on item's numeric and text attributes. Multiple attributes sorting is supported. Sorting of numeric custom attribute are also supported | 
Examples
Example 1 - Sort the results by a field named sale_price of type number in ascending order.
curl --location 'https://<PA_SEARCH_END_POINT>/v1.4/search' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer cGFTZXXXXXXXXXXXXXXXA==' \
    --data '{
        "customer_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "website_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "q": "SEARCH STRING",
        "client": "CLIENT SHORTCODE",
        "start": 0,
        "size": 1,
        "sort_fields":[{"sale_price":{"order":"asc", "type": "number"}}]
    }'
Example 2 - Sort the results by a field named org_price of type number in descending order.
curl --location 'https://<PA_SEARCH_END_POINT>/v1.4/search' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer cGFTZXXXXXXXXXXXXXXXA==' \
    --data '{
        "customer_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "website_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "q": "SEARCH STRING",
        "client": "CLIENT SHORTCODE",
        "start": 0,
        "size": 1,
        "sort_fields":[{"org_price":{"order":"desc", "type": "number"}}]
    }'
Example 3 - Sort the results by org_price followed by a field named title of type text in ascending order.
curl --location 'https://<PA_SEARCH_END_POINT>/v1.4/search' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer cGFTZXXXXXXXXXXXXXXXA==' \
    --data '{
        "customer_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "website_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "q": "SEARCH STRING",
        "client": "CLIENT SHORTCODE",
        "start": 0,
        "size": 1,
        "sort_fields":[{"org_price":{"order":"desc", "type": "number"}, {"title":{"order":"asc", "type": "text"}}}]
    }'
Response
{
  "payload": {
    ***,
    "result": [
      {
        ***,
        "availability": -1,
        "org_price": "10"
        "title": "Sample item 1",
        ***
      },
      {
        ***,
        "availability": -1,
        "org_price": "9"
        "title": "Sample item 2",
        ***
      },
      {
        ***,
        "availability": 0,
        "org_price": "11"
        "title": "Sample item 3",
        ***
      },
      {
        ***,
        "availability": 0,
        "org_price": "10"
        "title": "Sample item 4",
        ***
      }
    ],
    "total_results": 50,
    "suggestions" : {***},
    "redirects" : {***}
  },
  "type": 1
}