Search code examples
javascriptreactjsazureazure-cognitive-search

Azure Cognitive Search Demo App - Set number of results per page


I have downloaded the Demo App provided by Azure Portal, which implements Azure Cognitive Search. I've been trying to change the number of results per page to a different value, but I could not find any solution. The default number of results per page is 50. There are ways to change it if we created the code from scratch, but I am looking for an easier way to just plug it. As mentioned in the link https://github.com/jj09/azsearch.js we could alter the options using automagic, but no such way found to alter the number of results per page. Would be a great help if anyone could give me a solution for this.


Solution

  • You can specify the number of results using $top in the url. In the link you've shared, there's this setting:

    type SuggestionsParametersUpdate = {
            top?: number;
            filter?: string;
            orderby?: string;
            fuzzy?: boolean;
            highlightPreTag?: string;
            highlightPostTag?: string;
            select?: string;
            searchFields?: string;
            minimumCoverage?: string;
            apiVersion?: SearchApiVersion;
            suggesterName?: string;
        };
    

    try setting top parameter with value you want.