Apart from the general filters we’ve discussed, some filters are specific to one datasource- for example, Confluence has the author facet, and Slack has the channel facet. There are also custom facets that are defined for custom datasources pushed via api.

To uncover these datasource-specific facets, you can use our Glean UI to filter by the datasource you’re curious about. You will be able to find a list of facets for your search results, and facet values on the sidebar of the Glean UI (see image below).

Getting possible facets via Search API

If you would like to curl to get the facets, you can use a /search request to get the values that we use to populate the sidebar with a request like this:

{
    "query":"test",
    "pageSize":10,
    "requestOptions": {
        "facetBucketSize" : 3000,
        "facetFilters": [
            {
                "fieldName": "app",
                "values": [
                    {
                        "value": "confluence",
                        "relationType": "EQUALS"
                    }
                ]
            }
        ]
    }
}

This will return a top-level field, facetResults facetResults has the following relevant fields:

  1. sourceName - same as the facet fieldName in the facetFilters object
  2. operatorName - not relevant
  3. buckets - a list of facet bucket objects corresponding to a facet value
    1. The facet bucket object has the following relevant fields:
      1. count - the number of search results that would be returned if filtering by the facet value
      2. value - the facet value (ie “engineering” for the space facet)
        1. stringValue - the string value
        2. intValue- the integer value (not common)
        3. displayLabel - alternative value used for display in the UI
        4. iconConfig - optional image used to represent the facet value, such as a profile picture for people facet values.
{
    "sourceName": "space",
    "operatorName": "SelectMultiple",
    "buckets": [
        {
            "count": 3,
            "value": {
                "stringValue": "engineering"
            }
        }
    ]
}

To get all of the facets you can use with a particular datasource, you can look at all of the sourceNames in the facetsResults returned.

If latency is a concern, and you only want to receive facetResults, you can send a request with pageSize = 0, and add “FACET_RESULTS” within the responseHints field in requestOptions to not retrieve any documents and only retrieve facetResults. See sample request body below, which would gather facetResults for all confluence specific facets:

{
    "query":"test",
    "pageSize":0,
    "requestOptions": {
        "facetBucketSize":3000,
        "facetFilters": [
            {
                "fieldName": "app",
                "values": [
                    {
                        "value": "confluence",
                        "relationType": "EQUALS"
                    }
                ]
            }
        ],
        "responseHints": [
            "FACET_RESULTS"
        ]
    }
}