curl --request PUT \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id \
--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 '
{
"objectID": "my_composition_object_id",
"name": "my lovely crafted composition",
"description": "my lovely crafted composition that is used for X purpose",
"behavior": {
"injection": {
"main": {
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"analytics": true,
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"decompoundQuery": true,
"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"
],
"maxFacetHits": 10,
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "lorem",
"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": {
"facetSpecificList": {
"summary": "Specify which facet to retrieve with some marked as disjunctive",
"value": [
"category",
"disjunctive(brand)",
"price"
]
}
},
"hitsPerPage": 20,
"maxValuesPerFacet": 100,
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"lorem"
]
},
"values": {
"property1": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
},
"property2": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
}
}
},
"redirect": {
"url": "lorem"
},
"widgets": {
"banners": [
{
"image": {
"urls": [
{
"url": "lorem"
}
],
"title": "lorem"
},
"link": {
"url": "lorem"
}
}
]
}
},
"sortFacetValuesBy": "count",
"sumOrFiltersScores": false
}
}
}
},
"injectedItems": [
{
"key": "lorem",
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"analytics": true,
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"decompoundQuery": true,
"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"
],
"maxFacetHits": 10,
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "lorem",
"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
}
}
},
"position": 0,
"length": 0,
"metadata": {
"hits": {
"addItemKey": true,
"extra": {}
}
}
}
],
"deduplication": {
"positioning": "highest"
}
}
},
"sortingStrategy": {
"Price (asc)": "products-low-to-high",
"Price (desc)": "products-high-to-low"
}
}
'{
"taskID": 1514562690001
}Update and insert a composition in the current Algolia application.
curl --request PUT \
--url https://algolia_application_id.algolia.net/1/compositions/my_composition_object_id \
--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 '
{
"objectID": "my_composition_object_id",
"name": "my lovely crafted composition",
"description": "my lovely crafted composition that is used for X purpose",
"behavior": {
"injection": {
"main": {
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"analytics": true,
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"decompoundQuery": true,
"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"
],
"maxFacetHits": 10,
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "lorem",
"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": {
"facetSpecificList": {
"summary": "Specify which facet to retrieve with some marked as disjunctive",
"value": [
"category",
"disjunctive(brand)",
"price"
]
}
},
"hitsPerPage": 20,
"maxValuesPerFacet": 100,
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"lorem"
]
},
"values": {
"property1": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
},
"property2": {
"order": [
"lorem"
],
"sortRemainingBy": "count",
"hide": [
"lorem"
]
}
}
},
"redirect": {
"url": "lorem"
},
"widgets": {
"banners": [
{
"image": {
"urls": [
{
"url": "lorem"
}
],
"title": "lorem"
},
"link": {
"url": "lorem"
}
}
]
}
},
"sortFacetValuesBy": "count",
"sumOrFiltersScores": false
}
}
}
},
"injectedItems": [
{
"key": "lorem",
"source": {
"search": {
"index": "Products",
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"analytics": true,
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"clickAnalytics": false,
"decompoundQuery": true,
"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"
],
"maxFacetHits": 10,
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "lorem",
"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
}
}
},
"position": 0,
"length": 0,
"metadata": {
"hits": {
"addItemKey": true,
"extra": {}
}
}
}
],
"deduplication": {
"positioning": "highest"
}
}
},
"sortingStrategy": {
"Price (asc)": "products-low-to-high",
"Price (desc)": "products-high-to-low"
}
}
'{
"taskID": 1514562690001
}editSettingsYour 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"
Composition unique identifier.
"my_composition_object_id"
Composition name.
"my lovely crafted composition"
An object containing either an injection or multifeed behavior schema, but not both.
Show child attributes
Composition description.
"my lovely crafted composition that is used for X purpose"
A mapping of sorting labels to the indices (or replicas) that implement those sorting rules. The sorting indices MUST be related to the associated main targeted index in the composition. Each key is the label your frontend sends at runtime (for example, "Price (asc)"), and each value is the name of the index that should be queried when that label is selected.
When a request includes a "sortBy" parameter, the platform looks up the corresponding index in this mapping and uses it to execute the query. The main targeted index is replaced with the sorting strategy index it is mapped to.
Up to 20 sorting strategies can be defined.
Show child attributes
{
"Price (asc)": "products-low-to-high",
"Price (desc)": "products-high-to-low"
}OK
Unique identifier of a task.
A successful API response means that a task was added to a queue.
It might not run immediately.
You can check the task's progress with the task operation and this task ID.
1514562690001
Was this page helpful?