This page documents an earlier version of the API client. For the latest version, see Search for facet values.
search
This method lets you search through the values of a facet attribute and select a subset of those values that meet a given criteria.
Facet-searching only affects facet values, not the index search.
For a facet attribute to be searchable,
it must have been declared in the attributesForFaceting
index setting with the searchable
modifier.
By default:
- Results are sorted by decreasing count.
You can adjust with
sortFacetValuesBy
. - A maximum of 10 results are returned.
You can adjust with
maxFacetHits
.
search_for_facet_values
,
you allow your users to search within a specific faceted attribute
(for example, brands, authors, or categories) without needing to create a separate index.
You can still display the most common occurrences for each facet at the top,
but also enable users to search for a specific value for filtering.
Search for facet values doesn’t work if you have more than 65 searchable facets and searchable attributes combined:
any such search results in an empty list of facet values.
Examples
Search for facet values
Search for facet values with additional search parameters
Search for facet values and send extra HTTP headers
Parameters
Attribute name.For this to work, you must declare the attribute with
attributesForFaceting
using the searchable()
modifier.A mapping of request options with this method.
The mapping of search parameters used to search the underlying index.If set, the method will return facet values that both:
- Match the facet query
- Are contained in the records matching the regular search query
page
, hitsPerPage
, offset
, and length
parameters don’t affect the count, as the count value represents the whole set of results, not just the current page. maxFacetHits and sortFacetValuesBy do affect the returned facet values.Response
The number of times the value is present in the dataset.
Whether the count returned for each facetHit is exhaustive.
Highlighted value.
Processing time.
Facet value.
Response as JSON
This section shows the JSON response returned by the API. Each API client wraps this response in language-specific objects, so the structure may vary. To view the response, use thegetLogs
method.
Don’t rely on the order of properties—JSON objects don’t preserve key order.
JSON