curl --request POST \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/rules/search \
--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 '
{
"query": "",
"anchoring": "is",
"context": "mobile",
"page": 0,
"hitsPerPage": 20,
"enabled": true
}
'{
"hits": [
{
"consequence": {
"behavior": {
"injection": {
"main": {
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"disableExactOnAttributes": [
"description"
],
"disableTypoToleranceOnAttributes": [
"sku"
],
"distinct": 1,
"enableABTest": true,
"enablePersonalization": false,
"enableReRanking": true,
"enableRules": true,
"exactOnSingleWordQuery": "attribute",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"getRankingInfo": false,
"highlightPostTag": "</em>",
"highlightPreTag": "<em>",
"ignorePlurals": [
"ca",
"es"
],
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "<string>",
"percentileComputation": true,
"personalizationImpact": 100,
"queryLanguages": [
"es"
],
"queryType": "prefixLast",
"removeStopWords": [
"ca",
"es"
],
"removeWordsIfNoResults": "firstWords",
"replaceSynonymsInHighlight": false,
"responseFields": [
"*"
],
"restrictHighlightAndSnippetArrays": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"ruleContexts": [
"mobile"
],
"snippetEllipsisText": "โฆ",
"synonyms": true,
"typoTolerance": true,
"facetingAfterDistinct": false,
"facets": [
"category",
"disjunctive(brand)",
"price"
],
"hitsPerPage": 20,
"maxValuesPerFacet": 100,
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"title": "<string>",
"urls": [
{
"url": "<string>"
}
]
},
"link": {
"url": "<string>"
}
}
]
}
},
"sortFacetValuesBy": "count",
"sumOrFiltersScores": false
}
}
}
},
"deduplication": {
"positioning": "highest"
},
"injectedItems": [
{
"key": "<string>",
"length": 25,
"position": 49,
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"disableExactOnAttributes": [
"description"
],
"disableTypoToleranceOnAttributes": [
"sku"
],
"distinct": 1,
"enableABTest": true,
"enablePersonalization": false,
"enableReRanking": true,
"enableRules": true,
"exactOnSingleWordQuery": "attribute",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"getRankingInfo": false,
"highlightPostTag": "</em>",
"highlightPreTag": "<em>",
"ignorePlurals": [
"ca",
"es"
],
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "<string>",
"percentileComputation": true,
"personalizationImpact": 100,
"queryLanguages": [
"es"
],
"queryType": "prefixLast",
"removeStopWords": [
"ca",
"es"
],
"removeWordsIfNoResults": "firstWords",
"replaceSynonymsInHighlight": false,
"responseFields": [
"*"
],
"restrictHighlightAndSnippetArrays": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"ruleContexts": [
"mobile"
],
"snippetEllipsisText": "โฆ",
"synonyms": true,
"typoTolerance": true
}
}
},
"metadata": {
"hits": {
"addItemKey": true,
"extra": {}
}
}
}
]
}
}
},
"objectID": "my_composition_rule_object_id",
"conditions": [
{
"context": "mobile",
"filters": "genre:comedy",
"pattern": "{facet:genre}",
"sortBy": "price-low-to-high"
}
],
"description": "Display a promotional banner",
"enabled": true,
"tags": [
"conditional"
],
"validity": [
{
"from": 123,
"until": 123
}
]
}
],
"nbHits": 123,
"nbPages": 123,
"page": 123
}Search for composition rules
Searches for composition rules in your index.
curl --request POST \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id/rules/search \
--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 '
{
"query": "",
"anchoring": "is",
"context": "mobile",
"page": 0,
"hitsPerPage": 20,
"enabled": true
}
'{
"hits": [
{
"consequence": {
"behavior": {
"injection": {
"main": {
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"disableExactOnAttributes": [
"description"
],
"disableTypoToleranceOnAttributes": [
"sku"
],
"distinct": 1,
"enableABTest": true,
"enablePersonalization": false,
"enableReRanking": true,
"enableRules": true,
"exactOnSingleWordQuery": "attribute",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"getRankingInfo": false,
"highlightPostTag": "</em>",
"highlightPreTag": "<em>",
"ignorePlurals": [
"ca",
"es"
],
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "<string>",
"percentileComputation": true,
"personalizationImpact": 100,
"queryLanguages": [
"es"
],
"queryType": "prefixLast",
"removeStopWords": [
"ca",
"es"
],
"removeWordsIfNoResults": "firstWords",
"replaceSynonymsInHighlight": false,
"responseFields": [
"*"
],
"restrictHighlightAndSnippetArrays": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"ruleContexts": [
"mobile"
],
"snippetEllipsisText": "โฆ",
"synonyms": true,
"typoTolerance": true,
"facetingAfterDistinct": false,
"facets": [
"category",
"disjunctive(brand)",
"price"
],
"hitsPerPage": 20,
"maxValuesPerFacet": 100,
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"title": "<string>",
"urls": [
{
"url": "<string>"
}
]
},
"link": {
"url": "<string>"
}
}
]
}
},
"sortFacetValuesBy": "count",
"sumOrFiltersScores": false
}
}
}
},
"deduplication": {
"positioning": "highest"
},
"injectedItems": [
{
"key": "<string>",
"length": 25,
"position": 49,
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"disableExactOnAttributes": [
"description"
],
"disableTypoToleranceOnAttributes": [
"sku"
],
"distinct": 1,
"enableABTest": true,
"enablePersonalization": false,
"enableReRanking": true,
"enableRules": true,
"exactOnSingleWordQuery": "attribute",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"getRankingInfo": false,
"highlightPostTag": "</em>",
"highlightPreTag": "<em>",
"ignorePlurals": [
"ca",
"es"
],
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "<string>",
"percentileComputation": true,
"personalizationImpact": 100,
"queryLanguages": [
"es"
],
"queryType": "prefixLast",
"removeStopWords": [
"ca",
"es"
],
"removeWordsIfNoResults": "firstWords",
"replaceSynonymsInHighlight": false,
"responseFields": [
"*"
],
"restrictHighlightAndSnippetArrays": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"ruleContexts": [
"mobile"
],
"snippetEllipsisText": "โฆ",
"synonyms": true,
"typoTolerance": true
}
}
},
"metadata": {
"hits": {
"addItemKey": true,
"extra": {}
}
}
}
]
}
}
},
"objectID": "my_composition_rule_object_id",
"conditions": [
{
"context": "mobile",
"filters": "genre:comedy",
"pattern": "{facet:genre}",
"sortBy": "price-low-to-high"
}
],
"description": "Display a promotional banner",
"enabled": true,
"tags": [
"conditional"
],
"validity": [
{
"from": 123,
"until": 123
}
]
}
],
"nbHits": 123,
"nbPages": 123,
"page": 123
}settingsAuthorizations
Your 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.
Path Parameters
Unique Composition ObjectID. Composition unique identifier.
"my_composition_object_id"
Body
Composition Rules search parameters.
Which part of the search query the pattern should match:
startsWith. The pattern must match the beginning of the query.endsWith. The pattern must match the end of the query.is. The pattern must match the query exactly.contains. The pattern must match anywhere in the query.
Empty queries are only allowed as patterns with anchoring: is.
is, startsWith, endsWith, contains Only return composition rules that match the context (exact match).
"mobile"
If true, return only enabled composition rules.
If false, return only inactive composition rules.
By default, all composition rules are returned.
Maximum number of hits per page.
Algolia uses page and hitsPerPage to control how search results are displayed (paginated).
hitsPerPage: sets the number of search results (hits) displayed per page.page: specifies the page number of the search results you want to retrieve. Page numbering starts at 0, so the first page ispage=0, the second ispage=1, and so on.
For example, to display 10 results per page starting from the third page, set hitsPerPage to 10 and page to 2.
1 <= x <= 1000Requested page of the API response.
Algolia uses page and hitsPerPage to control how search results are displayed (paginated).
hitsPerPage: sets the number of search results (hits) displayed per page.page: specifies the page number of the search results you want to retrieve. Page numbering starts at 0, so the first page ispage=0, the second ispage=1, and so on.
For example, to display 10 results per page starting from the third page, set hitsPerPage to 10 and page to 2.
x >= 0Search query for rules.
Was this page helpful?