Return facet values beyond the maximum limit

In Sitecore Search, the default number of facets returned is 10. You can use the max parameter in the API request to set the number of facet values returned. However, there is an absolute maximum of 100 per request. There are times where you might need to return more than 100 facet values while ensuring performance and stability.

You can return results beyond the first 100 using one of the options:

  • The after parameter - pagination

  • The keyphrase parameter

Warning

You cannot use pagination and keyphrase filtering at the same time.

Use pagination

You can implement pagination within a facet value to enable returning all results. The after parameter returns all the results that are after the one defined in the facet ID.

Note

This requires that your facet is a term facet, sorted by text, and that asc or desc sorting is applied.

For example, if the first request returned 100 results, you can run another request where you set the last item you received in the after value. This will return results from 101 and onward. The following two sample requests and responses show how to do this.

This sample request shows how to request all category_breadcrumbs facets in alphabetical order (text, ascending) with the maximum limit of 100 using the following sample request:

{
    "widget": {
        "items": [
            {
                "rfk_id": "product_services",
                "search": {
                    "content": {},
                    "facet": {
                        "all": false,
                        "types": [
                            {
                                "name": "category_breadcrumbs",
                                "sort": {
                                    "name": "text",
                                    "order": "asc"
                                }
                            }
                        ],
                        "max": 100
                    },
                    "offset": 0,
                    "limit": 15
                },
                "entity": "content"
            }
        ]
    }
}

The response will show the first 100 facet values in alphabetical order. To preserve space, this sample response only shows the first value. 

{
    "widgets": [
        {
            "rfk_id": "product_services",
            "type": "preview_search",
            "used_in": "common_across_pages",
            "entity": "content",
            "facet": [
                {
                    "name": "category_breadcrumbs",
                    "label": "Category Breadcrumbs",
                    "value": [
                        
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6Ii9FbiBVc2RpZ2l0YWwgU29sdXRpb25zL09wdGltaXphdGlvbiJ9",
                            "text": “Digital Solutions/Optimization",
                            "count": 13
                        }
                    ]
                }
            ],
            "content": [
            
            ],
            "total_item": 2113,
            "limit": 15,
            "offset": 0
        }
    ],
    "dt": 12,
    "ts": 1734517554835
}

This sample request shows how to add the last facetid from the result above and put it in the after parameter.

{
    "widget": {
        "items": [
            {
                "rfk_id": "product_services",
                "search": {
                    "content": {},
                    "facet": {
                        "all": false,
                        "types": [
                            {
                                "name": "category_breadcrumbs",
                                "after": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6Ii9FbiBVc2RpZ2l0YWwgU29sdXRpb25zL09wdGltaXphdGlvbiJ9",
                                "sort": {
                                    "name": "text",
                                    "order": "asc"
                                }
                            }
                        ],
                        "max": 100
                    },
                    "offset": 0,
                    "limit": 15
                },
                "entity": "content"
            }
        ]
    }
}

This sample response shows how Sitecore Search returns another (up to) 100 facet values in alphabetical order, starting with the result after Digital Solutions/Optimization (we have only included two in this example):

{
    "widgets": [
        {
            "rfk_id": "product_services",
            "type": "preview_search",
            "used_in": "common_across_pages",
            "entity": "content",
            "facet": [
                {
                    "name": "category_breadcrumbs",
                    "label": "Category Breadcrumbs",
                    "value": [
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6Ii9FbiBVc2RpZ2l0YWwgU29sdXRpb25zL090aGVyIEluZHVzdHJpZXMifQ==",
                            "text": “Digital Solutions/Other Industries",
                            "count": 2
                        },
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6Ii9FbiBVc2RpZ2l0YWwgU29sdXRpb25zL1Byb2R1Y3Rpb24ifQ==",
                            "text": “Digital Solutions/Production",
                            "count": 17
                        },
                        
                    ]
                }
            ],
            "content": [
            
            ],
            "total_item": 2113,
            "limit": 15,
            "offset": 0
        }
    ],
    "dt": 21,
    "ts": 1734518180187
}

Use the keyphrase parameter

You can use the keyphrase parameter under widget.items.search.facet.types.keyphrase to search for the facet value. In the following example, Drilling.

This the sample request:

{
    "widget": {
        "items": [
            {
                "rfk_id": "product_services",
                "search": {
                    "content": {},
                    "facet": {
                        "all": false,
                        "types": [
                            {
                                "name": "category_breadcrumbs",
                                "keyphrase": "Drilling"
                            }
                        ]
                    },
                    "offset": 0,
                    "limit": 15
                },
                "entity": "content"
            }
        ]
    }
}

This is the sample response:

{
    "widgets": [
        {
            "rfk_id": "product_services",
            "type": "preview_search",
            "used_in": "common_across_pages",
            "entity": "content",
            "facet": [
                {
                    "name": "category_breadcrumbs",
                    "label": "Category Breadcrumbs",
                    "value": [
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6IkRyaWxsaW5nIn0=",
                            "text": "Drilling",
                            "count": 309
                        },
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6IkRyaWxsaW5nL0Rvd25ob2xlIERyaWxsaW5nIFRlY2hub2xvZ2llcyJ9",
                            "text": "Drilling/Downhole Drilling Technologies",
                            "count": 74
                        },
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6IkRyaWxsaW5nL0Zpc2hpbmcgVG9vbHMifQ==",
                            "text": "Drilling/Fishing Tools",
                            "count": 26
                        },
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6IkRyaWxsaW5nL0N1dHRpbmdzIGFuZCBXYXN0ZSBNYW5hZ2VtZW50In0=",
                            "text": "Drilling/Cuttings and Waste Management",
                            "count": 23
                        },
                        {
                            "id": "facetid_eyJ0eXBlIjoiZXEiLCJuYW1lIjoiY2F0ZWdvcnlfYnJlYWRjcnVtYnMiLCJ2YWx1ZSI6IkRyaWxsaW5nL0Rvd25ob2xlIERyaWxsaW5nIFRlY2hub2xvZ2llcy9EaXJlY3Rpb25hbCBTeXN0ZW1zIn0=",
                            "text": "Drilling/Downhole Drilling Technologies/Directional Systems",
                            "count": 23
                        }
                    ]
                }
            ],
            "content": [
               
            ],
            "total_item": 2113,
            "limit": 15,
            "offset": 0
        }
    ],
    "dt": 15,
    "ts": 1734519150250
}

For more information, see the Search and Recommendation API Reference documentation.

If you have suggestions for improving this article, let us know!