Tukaram Patil Pune
Tukaram Patil Pune

Reputation: 809

Retrieve faceted results with non default count value(10) from Azure Search

I am using the Azure index for an index search. My objective behind the Index search is to retrieve the Unique records depend upon some unique parameter say System_ID and I started using facets feature for this, but when using it I am unable to retrieve more than 10 unique facets despite providing a count value to 20 in the query.

Below is the summary:

Can you please help with me to modify it in such a way that I will get more than 10 records.

Any help will be appreciable. Default query:

$filter=(systemID ne null) and (ownerSalesforceRecordID eq 'a0h5B000000gJKfQAM')&facet=machineTagSystemID,sort:value&queryType=full

Default Results:

{"machineTagSystemID": [
            {
                "count": 9,
                "value": "ABCS  test machines-111-test - change|*1XA78RUGV23PVPN"
            },
            {
                "count": 6,
                "value": "Ajit Machine testing1jjcdxxxxxxxxxxxxxx|*1L693D439H5ZNG9"
            },
            {
                "count": 19,
                "value": "Anvesh test111dsaa|*13SSNP5AJ3L96C5"
            },
            {
                "count": 3,
                "value": "Dead End cross 2|*1NK7KNNLFVTM4QC"
            },
            {
                "count": 3,
                "value": "hehehe|*1NDC32TDNXT5RAH"
            },
            {
                "count": 14,
                "value": "high2 Machine12345678ppjk fvrf|*1T2F3VQEJ58ZLQL"
            },
            {
                "count": 31,
                "value": "prashant dev machine 213|*12L343TZTFGH3M6"
            },
            {
                "count": 1,
                "value": "ryansjcilaptop465986543|*1E2PG9V3BMEYDM7"
            },
            {
                "count": 12,
                "value": "snehali DEV June|*1QXEDL8E2V8MGBY"
            },
            {
                "count": 27,
                "value": "tarun Machine-dev|*1YRPHS3J7NGUVA8"
            }
        ]}

Facet with count:

$filter=(systemID ne null) and (ownerSalesforceRecordID eq 'a0h5B000000gJKfQAM')&facet=machineTagSystemID,sort:value,count:20&queryType=full

But same results:

{"machineTagSystemID": [
            {
                "count": 9,
                "value": "ABCS  test machines-111-test - change|*1XA78RUGV23PVPN"
            },
            {
                "count": 6,
                "value": "Ajit Machine testing1jjcdxxxxxxxxxxxxxx|*1L693D439H5ZNG9"
            },
            {
                "count": 19,
                "value": "Anvesh test111dsaa|*13SSNP5AJ3L96C5"
            },
            {
                "count": 3,
                "value": "Dead End cross 2|*1NK7KNNLFVTM4QC"
            },
            {
                "count": 3,
                "value": "hehehe|*1NDC32TDNXT5RAH"
            },
            {
                "count": 14,
                "value": "high2 Machine12345678ppjk fvrf|*1T2F3VQEJ58ZLQL"
            },
            {
                "count": 30,
                "value": "prashant dev machine 213|*12L343TZTFGH3M6"
            },
            {
                "count": 1,
                "value": "ryansjcilaptop465986543|*1E2PG9V3BMEYDM7"
            },
            {
                "count": 12,
                "value": "snehali DEV June|*1QXEDL8E2V8MGBY"
            },
            {
                "count": 27,
                "value": "tarun Machine-dev|*1YRPHS3J7NGUVA8"
            }
        ]}

This is based on the documentation link: https://learn.microsoft.com/en-us/azure/search/search-faceted-navigation

Upvotes: 5

Views: 1053

Answers (2)

Matt
Matt

Reputation: 13349

This is old but I hit the same issue - there is a default limit of 10 values returned in a facet, you can extend this to return more facet values by adding a count to a given facet. E.g.:

facet=Month,count:12&search=something

This can also be done in the c# API by just adding the count to the facet name:

var options = new SearchOptions();
options.Facets.Add("Month,count:12");

Upvotes: 2

Mike Carter - MSFT
Mike Carter - MSFT

Reputation: 163

Facets honor the filter specified in a query. It's possible this is why you are only seeing 10 unique facet value for this field. Generally speaking, your query looks fine. If there were more than 10 unique values in this field for the query specified, I would expect them to show up.

How many total results are returned by this query? I see 125 total values in the facets you provided and I'm wondering if the count aligns with your results.

Mike

Upvotes: 1

Related Questions