Interface InputSearchFacetConfig

Add custom facets that are not configured in dashboard.

There are 2 types of facets - stats and terms

Terms facet is used to get all values for a field with their counts. Example - get all available colors

{
"type": "terms",
"field": "customFields.item_color",
"order": "index",
"name": "Color"
}

Stats facet is used to calculate min and max values for a numeric field. Example - calculate price range of products

{
"id": "facet-id",
"field": "price",
"name": "Price",
"type": "stats"
}
interface InputSearchFacetConfig {
    enabled?: boolean;
    field?: string;
    id: string;
    infix?: string[];
    name?: string;
    order?: SearchFacetOrder;
    position?: number;
    prefix?: string[];
    size?: number;
    type?: SearchFacetType;
}

Properties

enabled?: boolean

If facet is disabled, it won't be calculated. Used to disable facets created in dashboard

field?: string

Field on which facet will be calculated

id: string

Facet ID

infix?: string[]

Adds a infix filter on facet's terms. Only applies if type is terms. Cannot be combined with prefix

name?: string

This name is returned with search response. Used as a display name in frontend

Returned facet order. Only applies if type is terms

position?: number

Returned facet position in search response facets array

prefix?: string[]

Adds a prefix filter on facet's terms. Only applies if type is terms. Cannot be combined with infix

size?: number

How many facet terms to return. Only applies if type is terms

Facet type