The filter request object
You can add a filter JSON object in a Sitecore Discover Search and Recommendation request to limit the types of content and facets you want returned. The value of the filter object is a value object. The value of the value object is a list containing either a <facet_id> or a <range_filter.
The following shows the structure of a filter object in a request:
{
"filter": {
"<facet_type>": {
"value": ["<filter_id>"]
}
}
}
Keys
The following table describes the keys that the filter object contains.
|
Key |
Type |
Description |
Value |
|---|---|---|---|
|
|
Required. The filters you want to apply to the request. |
|
The brand, category_names, price, and rating facet types are default and come with all implementations. You can define additional facet types that are specific to your industry when you do the initial data feed.
Filter type object
The following table describes the key in the Filter type object:
|
Key |
Type |
Description |
Value |
|---|---|---|---|
|
|
array |
Required. A list that contains the |
|
Example
The following example uses the exact values for a text filter (gender) and a range for a number filter (price):
{
"context": {
"page": {
"uri": "/mylandingpage"
}
},
"widget": {
"all": true
},
"facet": {
"all": true
},
"filter": {
"genders": {
"value": [
"unisex"
]
},
"price": {
"value": [
{
"min": 7,
"max": 70
}
]
}
},
"content": {
"product": {}
}
}The following example uses the facet_id for a text filter (gender) and a number filter (price):
{
"context": {
"page": {
"uri": "/mylandingpage"
}
},
"widget": {
"all": true
},
"facet": {
"all": true
},
"filter": {
"genders": {
"value": [
"facet_iddW5pc2V4"
]
},
"price": {
"value": [
"facet_ideyJtYXgiOjkwLCJtaW4iOjcwfQ=="
]
}
},
"content": {
"product": {}
}
}