Controlling facet types
Note
See Using faceted search for basic facet use cases.
To request specific facet types, you set the all flag to 1 and indicate the required facet type values.
The following examples continue the getting facet values from each facet type example.
Getting only color facets
In this example, you request three facet values from the colors facet.
Here is the request:
RequestResponse
{
"facet": {
"colors": {"max": 3}
}
}Here is the response:
RequestResponse
{
"ts": 1480977544,
"rid": "response_id_181",
"facet": {
"colors": {
"value": [
{"id": "color_id_red", "text": "Red", "count": 23},
{"id": "color_id_blue", "text": "Blue", "count": 11},
{"id": "color_id_yellow", "text": "Yellow", "count": 10}
]
}
},
"facet_names": ["colors"]
}Getting different facet value amounts
The following shows an example of getting different facet value amounts. In this example, you request five facet values for colors and three facets for product_type.
Here is the request:
RequestResponse
{
"facet": {
"colors": {
"max": 5
},
"product_type": {
"max": 3
}
}
}Here is the response:
RequestResponse
{
"ts": 1480977544,
"rid": "response_id_182",
"facet": {
"colors": {
"value": [
{"id": "color_id_red", "text": "Red", "count": 23},
{"id": "color_id_blue", "text": "Blue", "count": 11},
{"id": "color_id_yellow", "text": "Yellow", "count": 10},
{"id": "color_id_black", "text": "Black", "count": 8},
{"id": "color_id_white", "text": "White", "count": 1}
]
},
"product_type": {
"value": [
{"id": "prod_type_id_ring", "text": "Ring", "count": 105},
{"id": "prod_type_id_necklace", "text": "Necklace", "count": 45},
{"id": "prod_type_id_watch", "text": "Watch", "count": 5}
]
}
},
"facet_names": ["colors", "product_type"]
}