curl --request POST \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/facets/lorem/query \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '{"params":{"query":"","maxFacetHits":10,"searchQuery":{"analytics":true,"analyticsTags":[],"aroundLatLng":"40.71,-74.01","aroundLatLngViaIP":false,"aroundRadius":1,"aroundPrecision":10,"clickAnalytics":false,"enableABTest":true,"enablePersonalization":false,"enableReRanking":true,"enableRules":true,"facetFilters":[["category:Book","category:-Movie"],"author:John Doe"],"facets":{"facetSpecificList":{"summary":"Specify which facet to retrieve with some marked as disjunctive","value":[["category","disjunctive(brand)","price"]]},"facetAll":{"summary":"Retrieve all facets","value":[["*"]]}},"filters":"(category:Book OR category:Ebook) AND _tags:published","getRankingInfo":false,"hitsPerPage":20,"injectedItems":{"my-group-key":[{"objectID":"my-object-1","metadata":{"my-field":"my-value"}},{"objectID":"my-object-2"}]},"insideBoundingBox":"lorem","insidePolygon":[[47.3165,4.9665,47.3424,5.0201,47.32,4.9],[40.9234,2.1185,38.643,1.9916,39.2587,2.0104]],"minimumAroundRadius":1,"naturalLanguages":[],"numericFilters":[["inStock = 1","deliveryDate < 1441755506"],"price < 1000"],"optionalFilters":["category:Book","author:John Doe"],"page":0,"query":"","queryLanguages":["es"],"relevancyStrictness":90,"ruleContexts":["mobile"],"sortBy":"Price (asc)","userToken":"test-user-123"}}}'{
"results": [
{
"indexName": "<string>",
"facetHits": [
{
"value": "Mobile phone",
"highlighted": "<em>George</em> <em>Clo</em>oney",
"count": 123
}
],
"exhaustiveFacetsCount": true,
"processingTimeMS": 20
}
]
}Searches for values of a specified facet attribute on the composition’s main source’s index.
sortFacetValueBy parameter.curl --request POST \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/facets/lorem/query \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '{"params":{"query":"","maxFacetHits":10,"searchQuery":{"analytics":true,"analyticsTags":[],"aroundLatLng":"40.71,-74.01","aroundLatLngViaIP":false,"aroundRadius":1,"aroundPrecision":10,"clickAnalytics":false,"enableABTest":true,"enablePersonalization":false,"enableReRanking":true,"enableRules":true,"facetFilters":[["category:Book","category:-Movie"],"author:John Doe"],"facets":{"facetSpecificList":{"summary":"Specify which facet to retrieve with some marked as disjunctive","value":[["category","disjunctive(brand)","price"]]},"facetAll":{"summary":"Retrieve all facets","value":[["*"]]}},"filters":"(category:Book OR category:Ebook) AND _tags:published","getRankingInfo":false,"hitsPerPage":20,"injectedItems":{"my-group-key":[{"objectID":"my-object-1","metadata":{"my-field":"my-value"}},{"objectID":"my-object-2"}]},"insideBoundingBox":"lorem","insidePolygon":[[47.3165,4.9665,47.3424,5.0201,47.32,4.9],[40.9234,2.1185,38.643,1.9916,39.2587,2.0104]],"minimumAroundRadius":1,"naturalLanguages":[],"numericFilters":[["inStock = 1","deliveryDate < 1441755506"],"price < 1000"],"optionalFilters":["category:Book","author:John Doe"],"page":0,"query":"","queryLanguages":["es"],"relevancyStrictness":90,"ruleContexts":["mobile"],"sortBy":"Price (asc)","userToken":"test-user-123"}}}'{
"results": [
{
"indexName": "<string>",
"facetHits": [
{
"value": "Mobile phone",
"highlighted": "<em>George</em> <em>Clo</em>oney",
"count": 123
}
],
"exhaustiveFacetsCount": true,
"processingTimeMS": 20
}
]
}searchYour Algolia application ID.
Your Algolia API key with the necessary permissions to make the request. Permissions are controlled through access control lists (ACL) and access restrictions. The required ACL to make a request is listed in each endpoint's reference.
Unique Composition ObjectID. Composition unique identifier.
"my_composition_object_id"
Facet attribute in which to search for values.
This attribute must be included in the attributesForFaceting index setting with the searchable() modifier.
Show child attributes
Search query.
Maximum number of facet values to return when searching for facet values.
x <= 100Show child attributes
Whether this search will be included in Analytics.
Tags to apply to the query for segmenting analytics data.
Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude.
Only records included within a circle around this central location are included in the results.
The radius of the circle is determined by the aroundRadius and minimumAroundRadius settings.
This parameter is ignored if you also specify insidePolygon or insideBoundingBox.
"40.71,-74.01"
Whether to obtain the coordinates from the request's IP address.
Maximum radius for a search around a central location.
This parameter works in combination with the aroundLatLng and aroundLatLngViaIP parameters.
By default, the search radius is determined automatically from the density of hits around the central location.
The search radius is small if there are many hits close to the central coordinates.
x >= 1Precision of a coordinate-based search in meters to group results with similar distances.
The Geo ranking criterion considers all matches within the same range of distances to be equal.
Whether to include a queryID attribute in the response
The query ID is a unique identifier for a search query and is required for tracking click and conversion events.
Whether to enable index level A/B testing for this run request. If the composition mixes multiple indices, the A/B test is ignored.
Whether to enable Personalization.
Whether this search will use Dynamic Re-Ranking This setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard.
Whether to enable composition rules.
Filter the search by facet values, so that only records with the same facet values are retrieved.
Prefer using the filters parameter, which supports all filter types and combinations with boolean operators.
[filter1, filter2] is interpreted as filter1 AND filter2.[[filter1, filter2], filter3] is interpreted as filter1 OR filter2 AND filter3.facet:-value is interpreted as NOT facet:value.While it's best to avoid attributes that start with a -, you can still filter them by escaping with a backslash:
facet:\-value.
[
["category:Book", "category:-Movie"],
"author:John Doe"
]Facets for which to retrieve facet values that match the search criteria and the number of matching facet values
To retrieve all facets, use the wildcard character *.
To retrieve disjunctive facets lists, annotate any facets with the disjunctive modifier.
For more information, see facets and disjunctive faceting for Smart Groups.
{
"facetSpecificList": {
"summary": "Specify which facet to retrieve with some marked as disjunctive",
"value": [["category", "disjunctive(brand)", "price"]]
},
"facetAll": {
"summary": "Retrieve all facets",
"value": [["*"]]
}
}Filter expression to only include items that match the filter criteria in the response.
You can use these filter expressions:
<facet> <op> <number>, where <op> is one of <, <=, =, !=, >, >=.<facet>:<lower> TO <upper> where <lower> and <upper> are the lower and upper limits of the range (inclusive).<facet>:<value> where <facet> is a facet attribute (case-sensitive) and <value> a facet value._tags:<value> or just <value> (case-sensitive).<facet>: true | false.You can combine filters with AND, OR, and NOT operators with the following restrictions:
OR.
Not supported: facet:value OR num > 3.NOT with combinations of filters.
Not supported: NOT(facet:value OR facet:value)AND) with OR.
Not supported: facet:value OR (facet:value AND facet:value)Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (OR, AND, NOT), or quotes.
If a facet attribute is an array, the filter matches if it matches at least one element of the array.
For more information, see Filters.
"(category:Book OR category:Ebook) AND _tags:published"
Whether the run response should include detailed ranking information.
Number of hits per page.
1 <= x <= 1000A list of extenrally injected objectID groups into from an external source.
Show child attributes
Show child attributes
Show child attributes
An objectID injected into an external source.
User-defined key-values that will be added to the injected item in the response. This is identical to Hits metadata defined in Composition or Composition Rule, with the benefit of being set at runtime.
{ "my-field": "my-value" }{
"my-group-key": [
{
"objectID": "my-object-1",
"metadata": { "my-field": "my-value" }
},
{ "objectID": "my-object-2" }
]
}Coordinates of a polygon in which to search.
Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude.
Provide multiple polygons as nested arrays.
For more information, see filtering inside polygons.
This parameter is ignored if you also specify insideBoundingBox.
6 - 20000 elements[
[
47.3165,
4.9665,
47.3424,
5.0201,
47.32,
4.9
],
[
40.9234,
2.1185,
38.643,
1.9916,
39.2587,
2.0104
]
]Minimum radius (in meters) for a search around a location when aroundRadius isn't set.
x >= 1ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches)
removeStopWords and ignorePlurals to the list of provided languages.removeWordsIfNoResults to allOptional.natural_language attribute to ruleContexts and analyticsTags.ISO code for a supported language.
af, ar, az, bg, bn, ca, cs, cy, da, de, el, en, eo, es, et, eu, fa, fi, fo, fr, ga, gl, he, hi, hu, hy, id, is, it, ja, ka, kk, ko, ku, ky, lt, lv, mi, mn, mr, ms, mt, nb, nl, no, ns, pl, ps, pt, pt-br, qu, ro, ru, sk, sq, sv, sw, ta, te, th, tl, tn, tr, tt, uk, ur, uz, zh Filter by numeric facets.
Prefer using the filters parameter, which supports all filter types and combinations with boolean operators.
You can use numeric comparison operators: <, <=, =, !=, >, >=.
Comparisons are precise up to 3 decimals.
You can also provide ranges: facet:<lower> TO <upper>. The range includes the lower and upper boundaries.
The same combination rules apply as for facetFilters.
[
["inStock = 1", "deliveryDate < 1441755506"],
"price < 1000"
]Filters to promote or demote records in the search results.
Optional filters work like facet filters, but they don't exclude records from the search results.
Records that match the optional filter rank before records that don't match.
If you're using a negative filter facet:-value, matching records rank after records that don't match.
["category:Book", "author:John Doe"]Page of search results to retrieve.
x >= 0Search query.
Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries
This setting sets a default list of languages used by the removeStopWords and ignorePlurals settings.
This setting also sets a dictionary for word detection in the logogram-based CJK languages.
To support this, you must place the CJK language first
You should always specify a query language.
If you don't specify an indexing language, the search engine uses all supported languages,
or the languages you specified with the ignorePlurals or removeStopWords parameters.
This can lead to unexpected search results.
For more information, see Language-specific configuration.
ISO code for a supported language.
af, ar, az, bg, bn, ca, cs, cy, da, de, el, en, eo, es, et, eu, fa, fi, fo, fr, ga, gl, he, hi, hu, hy, id, is, it, ja, ka, kk, ko, ku, ky, lt, lv, mi, mn, mr, ms, mt, nb, nl, no, ns, pl, ps, pt, pt-br, qu, ro, ru, sk, sq, sv, sw, ta, te, th, tl, tn, tr, tt, uk, ur, uz, zh ["es"]Relevancy threshold below which less relevant results aren't included in the results
You can only set relevancyStrictness on virtual replica indices.
Use this setting to strike a balance between the relevance and number of returned results.
90
Assigns a rule context to the run query Rule contexts are strings that you can use to trigger matching rules.
["mobile"]Indicates which sorting strategy to apply for the request. The value must match one of the labels defined in the "sortingStrategy" mapping. For example, "Price (asc)", see Upsert Composition. At runtime, this label is used to look up the corresponding index or replica configured in "sortingStrategy", and the query is executed using that index instead of main's.
In addition to "sortingStrategy", this parameter is also used to apply a matching Composition Rule that contains a condition defined to trigger on "sortBy", see Composition Rules.
If no value is provided or an invalid value, no sorting strategy is applied.
"Price (asc)"
Unique pseudonymous or anonymous user identifier.
This helps with analytics and click and conversion events. For more information, see user token.
"test-user-123"
OK
Search for facet values results.
Show child attributes
Matching facet values.
Show child attributes
Facet value.
"Mobile phone"
Highlighted attribute value, including HTML tags.
"<em>George</em> <em>Clo</em>oney"
Number of records with this facet value. The count may be approximated.
Whether the facet count is exhaustive (true) or approximate (false). For more information, see Why are my facet and hit counts not accurate.
Time the server took to process the request, in milliseconds.
20
Was this page helpful?