Facets

Obtain values to filter on from results list

You can get the facets by sending a list of fields to enable faceting on.

  • For <<glossary:String>> fields, the API will return a list of unique values; For <<glossary:Long>> or <<glossary:Double>> type fields, the API will return a value range (min, max) as facet results.
  • Only facet values that exist in current search results will be returned.
  • Facet value list is ordered by the item count in descending order. facet counts are based on the top 1000 results.
  • There is no limitation for the number of fields to enable faceting.
  • When the value is set to all (facets = *), all the searchable fields will be used as facet fields.
Name Type (Default Value) Description

facets

String

List of product metadata fields to enable faceting.

facets_limit

Long (10)

The maximum number of facet values to be returned per facet field. Only non-numerical fields are supported.

facets_show_count

Boolean (False)

Option to show the facets count in the response. Item counts are based on the top 1000 results.

example response

{
  "status": "OK",
  "method": "product/search_by_image",
  "reqid": "1116464216832753388",
  "error": [],
  "page": 1,
  "limit": 2,
  "total": 1000,
  "result": [
    {
      "product_id": "3024",
      "main_image_url": "http://xx.com/test.jpg"
    },
    {
      "product_id": "OL13071",
      "main_image_url": "http://xx.com/test.jpg"
    }
  ],
  "facets": [
    {
      "key": "Brand",
      "items": [
        {
          "value": "BrandA",
          "count": 1
        },
        {
          "value": "BrandB",
          "count": 1
        }
      ]
    },
    {
      "key": "Gender",
      "items": [
        {
          "value": "Women",
          "count": 1
        },
        {
          "value": "Men",
          "count": 1
        }
      ]
    },
    {
      "key": "Price",
      "range": {
        "min": 10,
        "max": 20
      }
    }
  ]
}