curl --request POST \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/run \
--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":{"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": [
{
"page": 0,
"nbHits": 20,
"nbPages": 1,
"hitsPerPage": 20,
"hits": [
{
"objectID": "test-record-123",
"_highlightResult": {},
"_snippetResult": {},
"_rankingInfo": {
"firstMatchedWord": 1,
"geoDistance": 1,
"nbExactWords": 1,
"nbTypos": 1,
"userScore": 123,
"filters": 1,
"geoPrecision": 2,
"matchedGeoLocation": {
"lat": 123,
"lng": 123,
"distance": 123
},
"personalization": {
"filtersScore": 123,
"rankingScore": 123,
"score": 123
},
"promoted": true,
"proximityDistance": 1,
"words": 2,
"promotedByReRanking": true,
"composed": {}
},
"_distinctSeqID": 123,
"_extra": {
"_injectedItemKey": "<string>"
}
}
],
"query": "",
"params": "query=a&hitsPerPage=20",
"compositions": {},
"abTestID": 123,
"abTestVariantID": 2,
"aroundLatLng": "40.71,-74.01",
"automaticRadius": "<string>",
"exhaustive": {
"facetsCount": true,
"facetValues": true,
"nbHits": true,
"rulesMatch": true,
"typo": true
},
"appliedRules": [
{}
],
"exhaustiveFacetsCount": true,
"exhaustiveNbHits": true,
"exhaustiveTypo": true,
"facets": {
"category": {
"food": 1,
"tech": 42
}
},
"facets_stats": {},
"index": "indexName",
"indexUsed": "indexNameAlt",
"message": "<string>",
"nbSortedHits": 20,
"parsedQuery": "george clo",
"processingTimeMS": 20,
"processingTimingsMS": {},
"queryAfterRemoval": "<string>",
"redirect": {
"index": [
{
"source": "<string>",
"dest": "<string>",
"reason": "<string>",
"succeed": true,
"data": {
"ruleObjectID": "<string>"
}
}
]
},
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"urls": [
{
"url": "<string>"
}
],
"title": "<string>"
},
"link": {
"url": "<string>"
}
}
]
}
},
"serverTimeMS": 20,
"serverUsed": "c2-uk-3.algolia.net",
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
},
"queryID": "a00dbc80a8d13c4565a442e7e2dca80a",
"_automaticInsights": true
}
],
"compositions": {
"run": [
{
"objectID": "test-record-123",
"appliedRules": [
{
"objectID": "test-record-123"
}
]
}
]
}
}Runs a query on a single composition and returns matching results.
curl --request POST \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/run \
--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":{"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": [
{
"page": 0,
"nbHits": 20,
"nbPages": 1,
"hitsPerPage": 20,
"hits": [
{
"objectID": "test-record-123",
"_highlightResult": {},
"_snippetResult": {},
"_rankingInfo": {
"firstMatchedWord": 1,
"geoDistance": 1,
"nbExactWords": 1,
"nbTypos": 1,
"userScore": 123,
"filters": 1,
"geoPrecision": 2,
"matchedGeoLocation": {
"lat": 123,
"lng": 123,
"distance": 123
},
"personalization": {
"filtersScore": 123,
"rankingScore": 123,
"score": 123
},
"promoted": true,
"proximityDistance": 1,
"words": 2,
"promotedByReRanking": true,
"composed": {}
},
"_distinctSeqID": 123,
"_extra": {
"_injectedItemKey": "<string>"
}
}
],
"query": "",
"params": "query=a&hitsPerPage=20",
"compositions": {},
"abTestID": 123,
"abTestVariantID": 2,
"aroundLatLng": "40.71,-74.01",
"automaticRadius": "<string>",
"exhaustive": {
"facetsCount": true,
"facetValues": true,
"nbHits": true,
"rulesMatch": true,
"typo": true
},
"appliedRules": [
{}
],
"exhaustiveFacetsCount": true,
"exhaustiveNbHits": true,
"exhaustiveTypo": true,
"facets": {
"category": {
"food": 1,
"tech": 42
}
},
"facets_stats": {},
"index": "indexName",
"indexUsed": "indexNameAlt",
"message": "<string>",
"nbSortedHits": 20,
"parsedQuery": "george clo",
"processingTimeMS": 20,
"processingTimingsMS": {},
"queryAfterRemoval": "<string>",
"redirect": {
"index": [
{
"source": "<string>",
"dest": "<string>",
"reason": "<string>",
"succeed": true,
"data": {
"ruleObjectID": "<string>"
}
}
]
},
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"urls": [
{
"url": "<string>"
}
],
"title": "<string>"
},
"link": {
"url": "<string>"
}
}
]
}
},
"serverTimeMS": 20,
"serverUsed": "c2-uk-3.algolia.net",
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
},
"queryID": "a00dbc80a8d13c4565a442e7e2dca80a",
"_automaticInsights": true
}
],
"compositions": {
"run": [
{
"objectID": "test-record-123",
"appliedRules": [
{
"objectID": "test-record-123"
}
]
}
]
}
}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"
Show 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 results.
Show child attributes
Page of search results to retrieve.
x >= 0Number of results (hits).
20
Number of pages of results.
1
Number of hits per page.
1 <= x <= 1000Search results (hits).
Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
Show child attributes
Unique record identifier.
"test-record-123"
Surround words that match the query with HTML tags for highlighting.
Show child attributes
Surround words that match the query with HTML tags for highlighting.
Show child attributes
Highlighted attribute value, including HTML tags.
"<em>George</em> <em>Clo</em>oney"
Whether the whole query string matches or only a part.
none, partial, full List of matched words from the search query.
["action"]Whether the entire attribute value is highlighted.
Snippets that show the context around a matching search query.
Show child attributes
Snippets that show the context around a matching search query.
Show child attributes
Highlighted attribute value, including HTML tags.
"<em>George</em> <em>Clo</em>oney"
Whether the whole query string matches or only a part.
none, partial, full Object with detailed information about the record's ranking.
Show child attributes
Position of the first matched word in the best matching attribute of the record.
x >= 0Distance between the geo location in the search query and the best matching geo location in the record, divided by the geo precision (in meters).
x >= 0Number of exactly matched words.
x >= 0Number of typos encountered when matching the record.
x >= 0Overall ranking of the record, expressed as a single integer. This attribute is internal.
Whether a filter matched the query.
x >= 0Precision used when computing the geo distance, in meters.
x >= 1Show child attributes
Latitude of the matched location.
Longitude of the matched location.
Distance between the matched location and the search location (in meters).
Whether the record was promoted by a rule.
Number of words between multiple matches in the query plus 1. For single word queries, proximityDistance is 0.
x >= 0Number of matched words.
x >= 1Whether the record is re-ranked.
Search query.
URL-encoded string of all search parameters.
"query=a&hitsPerPage=20"
Show child attributes
Show child attributes
Show child attributes
A/B test ID. This is only included in the response for indices that are part of an A/B test.
Variant ID. This is only included in the response for indices that are part of an A/B test.
x >= 1Computed geographical location.
"40.71,-74.01"
Distance from a central coordinate provided by aroundLatLng.
Whether certain properties of the search response are calculated exhaustive (exact) or approximated.
Show child attributes
Whether the facet count is exhaustive (true) or approximate (false). See the related discussion.
The value is false if not all facet values are retrieved.
Whether the nbHits is exhaustive (true) or approximate (false). When the query takes more than 50ms to be processed, the engine makes an approximation. This can happen when using complex filters on millions of records, when typo-tolerance was not exhaustive, or when enough hits have been retrieved (for example, after the engine finds 10,000 exact matches). nbHits is reported as non-exhaustive whenever an approximation is made, even if the approximation didn’t, in the end, impact the exhaustivity of the query.
Rules matching exhaustivity. The value is false if rules were enable for this query, and could not be fully processed due a timeout. This is generally caused by the number of alternatives (such as typos) which is too large.
Whether the typo search was exhaustive (true) or approximate (false). An approximation is done when the typo search query part takes more than 10% of the query budget (ie. 5ms by default) to be processed (this can happen when a lot of typo alternatives exist for the query). This field will not be included when typo-tolerance is entirely disabled.
Rules applied to the query.
See the facetsCount field of the exhaustive object in the response.
See the nbHits field of the exhaustive object in the response.
See the typo field of the exhaustive object in the response.
Statistics for numerical facets.
Show child attributes
Show child attributes
Minimum value in the results.
Maximum value in the results.
Average facet value in the results.
Sum of all values in the results.
Index name used for the query.
"indexName"
Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query.
"indexNameAlt"
Warnings about the query.
Number of hits selected and sorted by the relevant sort algorithm.
20
Post-normalization query string that will be searched.
"george clo"
Time the server took to process the request, in milliseconds.
20
Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate performance issues.
Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set.
Redirect results to a URL, this this parameter is for internal use only.
Show child attributes
Show child attributes
Source index for the redirect rule.
Destination index for the redirect rule.
Reason for the redirect rule.
Redirect rule status.
Extra data that can be used in the search UI.
You can use this to control aspects of your search UI, such as the order of facet names and values without changing your frontend code.
Show child attributes
Order of facet names and facet values in your UI.
Show child attributes
Order of facet values. One object for each facet.
Show child attributes
Show child attributes
Explicit order of facets or facet values.
This setting lets you always show specific facets or facet values at the top of the list.
Order of facet values that aren't explicitly positioned with the order setting.
count.
Order remaining facet values by decreasing count.
The count is the number of matching records containing this facet value.
alpha.
Sort facet values alphabetically.
hidden.
Don't show facet values that aren't explicitly positioned.
count, alpha, hidden Hide facet values.
Widgets returned from any rules that are applied to the current search.
Show child attributes
Banners defined in the Merchandising Studio for a given search.
Show child attributes
Time the server took to process the request, in milliseconds.
20
Host name of the server that processed the request.
"c2-uk-3.algolia.net"
An object with custom data.
You can store up to 32kB as custom data.
{
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
}Unique identifier for the query. This is used for click analytics.
"a00dbc80a8d13c4565a442e7e2dca80a"
Whether automatic events collection is enabled for the application.
Show child attributes
Show child attributes
Was this page helpful?